当前位置: 首页>>代码示例>>C#>>正文


C# CultureInfo.ToLower方法代码示例

本文整理汇总了C#中System.Globalization.CultureInfo.ToLower方法的典型用法代码示例。如果您正苦于以下问题:C# CultureInfo.ToLower方法的具体用法?C# CultureInfo.ToLower怎么用?C# CultureInfo.ToLower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Globalization.CultureInfo的用法示例。


在下文中一共展示了CultureInfo.ToLower方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestFrFRUpperCaseCharacter

 public void TestFrFRUpperCaseCharacter()
 {
     char ch = 'G';
     char expectedChar = 'g';
     TextInfo textInfo = new CultureInfo("fr-FR").TextInfo;
     char actualChar = textInfo.ToLower(ch);
     Assert.Equal(expectedChar, actualChar);
 }
开发者ID:jmhardison,项目名称:corefx,代码行数:8,代码来源:TextInfoToLower.cs

示例2: TestEnUSLowercaseCharacter

        public void TestEnUSLowercaseCharacter()
        {
            char ch = 'a';
            char expectedChar = ch;
            TextInfo textInfo = new CultureInfo("en-US").TextInfo;

            char actualChar = textInfo.ToLower(ch);
            Assert.Equal(expectedChar, actualChar);
        }
开发者ID:jmhardison,项目名称:corefx,代码行数:9,代码来源:TextInfoToLower.cs

示例3: checkMiddle

        /// <summary>
        /// Prompts the user for a standard input (AKA console) input to whether they wish to enter a middle name or not
        /// </summary>
        private void checkMiddle()
        {
            TextInfo ti = new CultureInfo("en-US", false).TextInfo;

            Console.WriteLine("Do you have a middle name? [Y/N]");
            if (String.Compare(ti.ToLower(readString()), "y") == 0)
                hasMiddle = true;
            else
                hasMiddle = false;
        }
开发者ID:safderiqbal,项目名称:Learning-C-,代码行数:13,代码来源:HelloWorld.cs

示例4: TestNonAlphabeticCharacter

        public void TestNonAlphabeticCharacter()
        {
            for (int i = 0; i <= 9; i++)
            {
                char ch = Convert.ToChar(i);
                char expectedChar = ch;
                TextInfo textInfo = new CultureInfo("en-US").TextInfo;

                char actualChar = textInfo.ToLower(ch);
                Assert.Equal(expectedChar, actualChar);
            }
        }
开发者ID:jmhardison,项目名称:corefx,代码行数:12,代码来源:TextInfoToLower.cs

示例5: toProper

        public static String toProper(String columnString) {

            // Creates a TextInfo object from which the method will apply the casing rules
            var myTI = new CultureInfo("en-US", false).TextInfo;

            // Constructs the proper cased string
            var retval = myTI.ToTitleCase(myTI.ToLower(columnString));

            // Returns the String to the caller
            return retval;

        } // End of Method declaration
开发者ID:wbuchanan,项目名称:whyWontSQLServerImplementRegexNatively,代码行数:12,代码来源:SQLServerToProper.cs

示例6: TestTrTRUppercaseCharacter

        public void TestTrTRUppercaseCharacter()
        {
            char ch = '\u0130';
            char expectedChar = 'i';
            TextInfo textInfo = new CultureInfo("tr-TR").TextInfo;

            char actualChar = textInfo.ToLower(ch);
            Assert.Equal(expectedChar, actualChar);

            ch = 'I';
            expectedChar = '\u0131';
            actualChar = textInfo.ToLower(ch);
            Assert.Equal(expectedChar, actualChar);
        }
开发者ID:jmhardison,项目名称:corefx,代码行数:14,代码来源:TextInfoToLower.cs

示例7: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            string usernameCookie = "";

            if (Request.Cookies["user"] != null)
            { //If cookie exist, get username
                
                HttpCookie getUserCookie = Request.Cookies["user"];

                usernameCookie = getUserCookie.Values["username"];
                string userType = getUserCookie.Values["usertype"];

                switch (userType)
                {
                    case "s":
                        userProfileHomeID.Attributes["href"] = String.Format("UserProfile.aspx");
                        break;

                    case "r":
                        userProfileHomeID.Attributes["href"] = String.Format("ReviewerProfile.aspx");
                        break;

                    case "a":
                        userProfileHomeID.Attributes["href"] = String.Format("Admin_Dashboard_Main.aspx");
                        break;
                }
            }
            else
            {
                Response.Redirect("A_Login.aspx");
            }


            string firstName = "";
            string lastName = "";
            string finalFirstName = "";
            string finalLastName = "";
            string finalFullName = "";
            string emailAddress = "";
            string finalEmailAddress = "";
            string collegeDepartment = "";
            string finalCollegeDepartment = "";
            string username = usernameCookie;
            string picFileName = "";

            //username = Request.QueryString["u.username"];



            string connectionString;
            connectionString = ConfigurationManager.ConnectionStrings["ConnectionStringLocalDB"].ConnectionString;
            using (SqlConnection connection = new SqlConnection(connectionString)) {
                using (SqlCommand command = connection.CreateCommand()) { 
                    command.CommandText=
                        "SELECT "+
                        "First_Name, "+
                        "Last_Name, "+
                        "College_Dept, "+
                        "Email, " +
                        "Comment_Box " +
                        "FROM "+
                        "dbo.USERS "+
                        "WHERE username = @usernameDB";
                    command.Parameters.AddWithValue("@usernameDB", username);
                    try
                    {
                        connection.Open();
                        SqlDataReader reader = command.ExecuteReader();
                        if (reader.HasRows) {
                            while (reader.Read()) {
                                firstName = reader.GetString(0);
                                lastName = reader.GetString(1);
                                collegeDepartment = reader.GetString(2);
                                emailAddress = reader.GetString(3);
                                picFileName = reader.GetString(4);

                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }

                    finally
                    {
                        connection.Close();
                    }
                }
            }

            //Define object to make string proper case
            TextInfo titleCase = new CultureInfo("en-US", false).TextInfo;

            finalFirstName = titleCase.ToTitleCase(firstName.ToLower());
            finalLastName = titleCase.ToTitleCase(lastName);
            finalFullName = finalFirstName + " " + finalLastName;
            finalEmailAddress = titleCase.ToLower(emailAddress);
            reviewerUserID.Text = finalFirstName + " " + finalLastName;
            profileNameID.Text = finalFullName;
//.........这里部分代码省略.........
开发者ID:abhishek0066,项目名称:Reggi_Scholar_.NET_WebApplication,代码行数:101,代码来源:ReviewerProfile.aspx.cs

示例8: getName

        /// <summary>
        /// Utilises CultureInfo to detect which part of the name the user is attempting to input, as well as resolving any issues with case.
        /// </summary>
        /// <param name="control">Switch info: 1 = First Name, 2 = Middle Name (if applicable), 3 = Surname</param>
        /// <returns>-1 on failure</returns>
        private int getName(int control)
        {
            if (control < 0 || control > 3)
                return -1;

            TextInfo ti = new CultureInfo("en-US", false).TextInfo;

            switch (control)
            {
                case 1:
                    {
                        Console.WriteLine("Please enter your first name: ");
                        first = ti.ToTitleCase(ti.ToLower(readString()));
                        return 0;
                    } // 1
                case 2:
                    {
                        Console.WriteLine("Please enter your middle name/s: ");
                        middle = ti.ToTitleCase(ti.ToLower(readString()));
                        return 0;
                    } // 2
                case 3:
                    {
                        Console.WriteLine("Please enter your surname: ");
                        surname = ti.ToTitleCase(ti.ToLower(readString()));
                        return 0;
                    } // 3
                default:
                    return -1;
            } // switch
        }
开发者ID:safderiqbal,项目名称:Learning-C-,代码行数:36,代码来源:HelloWorld.cs

示例9: Page_Load


//.........这里部分代码省略.........
                                    FilesUpload_Date = reader.GetDateTime(36);
                                    FilesReject_Reason = reader.GetString(37);
                                    FilesNum_Views = reader.GetInt32(38);
                                    FilesNum_Dloads = reader.GetInt32(39);
                                    FilesPic_File = reader.GetString(40);
                                    FilesProj_Pdf_File = reader.GetString(41);
                                    FilesProj_Zip_File = reader.GetString(42);
                                    FilesPres_Date = reader.GetString(43);
                                    FilesDislike_Count = reader.GetInt32(44);
                                    FilesLike_Count = reader.GetInt32(45);
                                    FilesApproval_Status1 = reader.GetString(46);
                                    FilesApproval_Status2 = reader.GetString(47);
                                    FilesApproval_Status3 = reader.GetString(48);
                                    FilesReviewer_Comment1 = reader.GetString(49);
                                    FilesReviewer_Comment2 = reader.GetString(50);
                                    FilesReviewer_Comment3 = reader.GetString(51);
                                }
                            }
                        }
                        catch (Exception ex) {
                            Console.WriteLine(ex.Message);
                        }
                    } //End SqlCommand
                } //End SqlConnection

                //Define object to make string proper case
                TextInfo titleCase = new CultureInfo("en-US", false).TextInfo;

                rejectID.Text = FilesReviewer_Comment1 + "  " + FilesReviewer_Comment2 + "  " + FilesReviewer_Comment3;
                commentSectionID.Text = UserComment_BoxDB;
                finalAdvisorName = titleCase.ToTitleCase(FilesGadvisor_Name);
                finalCommitteeChairName = titleCase.ToTitleCase(FilesChair_Name);
                finalCommitteeMemberName = titleCase.ToTitleCase(FilesComm_Name); 
                string firstNameProperCase = titleCase.ToTitleCase(UserFirst_NameDB.ToLower());
                string lastNameProperCase = titleCase.ToTitleCase(UserLast_NameDB);
                presentationDateID.Text = FilesPres_Date;
                headerUserNameID.Text = firstNameProperCase + " " + lastNameProperCase;
                FullNameLabel.Text = titleCase.ToTitleCase(UserFirst_NameDB.ToLower()) + " " + titleCase.ToTitleCase(UserLast_NameDB.ToLower());
                
                LastLoginLabel.Text = Last_Login.ToString("G");
                CourseNumberLabel.Text = FilesCourse_ID;
                DepartmentLabel.Text = UserCollege_DeptDB;
                SemesterCompletedLabel.Text = UserSemester_CompletionDB;
                EmailLabel.Text = titleCase.ToLower(UserEmailDB);
                
                AccountCreatedDateLabel.Text = UserAccount_DateDB.ToString("G");
                AccountReasonLabel.Text = titleCase.ToTitleCase(UserAcct_ReasonDB);

                string statusString = "";
                if (Approve_Status == "y") {
                    statusString = "Approved";
                }
                else {
                    statusString = "Not Approved";
                }

                AccountApprovedLabel.Text = statusString;
                
                firstNameId.Text = titleCase.ToTitleCase(UserFirst_NameDB);
                lastNameId.Text = titleCase.ToTitleCase(UserLast_NameDB);
                userNameId.Text = UserUsernameDB;
                passwordId.Attributes.Add("value", userPasswordFromCookie);

                emailId.Text = UserEmailDB;
                securityQuestionID.Text = UserSecurity_QuestionDB;
                securityAnswerID.Text = UserSecurity_AnswerDB;
开发者ID:abhishek0066,项目名称:Reggi_Scholar_.NET_WebApplication,代码行数:67,代码来源:UserProfile.aspx.cs

示例10: play

        private static void play()
        {
            Console.WriteLine("Would you prefer what is behind door number 1, 2, or 3?");
            int min = 1;
            int max = 4;

            // Load the random numbers
            ArrayList availableNumbers = new ArrayList();
            for (int i = min; i < max; i++)
                availableNumbers.Add(i);

            // Assign the first number to the car's door number
            int carValue = RandomNumber(min, max);
            availableNumbers.Remove(carValue);
            int boatValue = carValue;
            int catValue;
            string message;

            // Randomly search for a value for the boat's door number
            while (!availableNumbers.Contains(boatValue))
                boatValue = RandomNumber(min, max);
            availableNumbers.Remove(boatValue);

            // Assign the cat value the remaining number
            catValue = (int)availableNumbers[0];

            // DEBUG
            //Console.WriteLine(String.Format("CarValue: {0} BoatValue: {1} CatValue: {2}",carValue,boatValue,catValue));

            // Read the user input
            int userValue = readNumber(min, max);

            // The 'CatValue' variable now only holds debug purposes, due to sufficient validation on the integer input
            if (userValue == carValue)
                message = "You won a new car!";
            else if (userValue == boatValue)
                message = "You won a new boat!";
            else
                message = "You won a new cat!";

            Console.WriteLine(message);

            Console.WriteLine("Do you want to play again? [Y/N]");
            TextInfo ti = new CultureInfo("en-US", false).TextInfo;
            if (String.Compare(ti.ToLower(readString()), "y") == 0)
            {
                // Repeat
                Console.WriteLine("");
                play();
            }
            else
                // Cleanly exit
                Environment.Exit(-1);
        }
开发者ID:safderiqbal,项目名称:Learning-C-,代码行数:54,代码来源:Program.cs

示例11: string_advanced_examples

        public string_advanced_examples()
        {
            //escape sequences
            string tab = "This is a\t tab.";
            string charLiterals = "This is a\' break.";
            string newLine = "This is a\n new line.";
            string backslash = "This is a \\ backslash because otherwise it wouldn't work properly and it would throw an error.";
            string backspace = "this is a backspace \b";
            string carriageReturn = "This is a \r carriage return";

            /*-----------------------------------------------------
            * All escape sequences
            * ---------------------------------------------------*/
            //\' - single quote, needed for character literals
            //\" - double quote, needed for string literals
            //\\ - backslash
            //\0 - Unicode character 0 (ASCII)
            //\a - Alert (character 7)
            //\b - Backspace (character 8)
            //\f - Form feed (character 12)
            //\n - New line (character 10)
            //\r - Carriage return (character 13)
            //\t - Horizontal tab (character 9)
            //\v - Vertical quote (character 11)
            //\uxxxx - Unicode escape sequence for character with hex value xxxx
            //\xn[n][n][n] - Unicode escape sequence for character with hex value nnnn (variable length version of \uxxxx)
            //\Uxxxxxxxx - Unicode escape sequence for character with hex value xxxxxxxx (for generating surrogates)

            //verbatims
            //In a verbatim string literal, the characters between the delimiters are interpreted verbatim, the only exception being a quote-escape-sequence. In particular, simple escape sequences and hexadecimal and Unicode escape sequences are not processed in verbatim string literals. A verbatim string literal may span multiple lines.
            string verbatim = @"And she said, 'Johnny knows the world is cruel but he loves 'it' anyways'.";
            Console.WriteLine(verbatim);
            //verbatims appear "as-is", meaning it is cleaner and easier to program. You don't need to use escape sequences all over the place.

            //case manipulation
            Console.WriteLine("\nBegin String case manipulation\n");
            string monkey = "monKEYs aRE WILD animals.";
            Console.WriteLine("\"{0}\" string lower case: {1}", monkey, monkey.ToLower());// this should take the string and put everything in lower case.
            Console.WriteLine("\"{0}\" string upper case: {1}", monkey, monkey.ToUpper());// this should take the string and put everything in upper case.

            TextInfo ti = new CultureInfo("en-US", false).TextInfo;
            Console.WriteLine("\"{0}\" textinfo upper case: {1}", monkey, ti.ToUpper(monkey));// this should take the string and put everything in upper case.
            Console.WriteLine("\"{0}\" textinfo lower case: {1}", monkey, ti.ToLower(monkey));// this should take the string and put everything in lower case.
            Console.WriteLine("\"{0}\" textinfo titled case: {1}", monkey, ti.ToTitleCase(monkey));// this should take the string and put everything in titled case.

            string bubby = "   asdf a sdfsd  sd  f d  f f     ";
            bubby = bubby.Trim();// removes all white spaces and non-alphabetic characters.
            Console.WriteLine("The new and improved bubby is: " + bubby);

            //i have no idea what these do.
            bubby = bubby.PadLeft(17, 'a');
            Console.WriteLine(bubby);
            bubby = bubby.PadRight(5, 'u');
            Console.WriteLine(bubby);

            string attack = "Yummy people are awkward to socalize with.";
            Console.WriteLine("Length of attack var is " + attack.Length);//this returns the number of characters of the string. Cannot be invoked like Java.

            bool check = true;

            while (check == true)
            {

                if (attack.Contains(':') || attack.Contains('@') || attack.Contains('.') || attack.Contains('='))
                {
                    Console.WriteLine("A SQL injection attempt has been detected. Cleaning input now.");
                    attack = attack.Replace('.', ' ');
                    attack = attack.Replace('@', ' ');
                    attack = attack.Replace(':', ' ');
                    attack = attack.Replace('=', ' ');

                    check = true;//this type of logic could be used to check for invalid input that might be used in a SQL injection attack.
                }
                else
                {
                    Console.WriteLine("SQL injection check completed. As you were.");
                    check = false;
                }

            }

            //concationating strings
            string hank = "Hank Hill";
            string peggy = "Peggy Hill";
            string married = "are married.";
            Console.WriteLine(hank + " and " + peggy + " " + married);
            //similar way to do this:
            Console.WriteLine("{0} and {1} {2}", hank, peggy, married);// don't have to type as many pluses and "" things.

            //concatination is slow. Use the String Builder class for larger strings.
            StringBuilder sbuild = new StringBuilder();
            sbuild.Append(hank);
            sbuild.Append(" and ");
            sbuild.Append(peggy);
            sbuild.Append(" ");
            sbuild.Append(married);

            Console.WriteLine(sbuild);
            //although there is no output difference this method is more efficient.
        }
开发者ID:jcoddaire,项目名称:C-Sharp-Code,代码行数:100,代码来源:string_advanced_examples.cs

示例12: MatchEvalChangeCase

        // regex match evaluator for changing case
        private string MatchEvalChangeCase( Match match )
        {
            TextInfo ti = new CultureInfo( "en" ).TextInfo;

              if     ( itmChangeCaseUppercase.Checked ) return ti.ToUpper( match.Groups[1].Value );
              else if( itmChangeCaseLowercase.Checked ) return ti.ToLower( match.Groups[1].Value );
              else if( itmChangeCaseTitlecase.Checked ) return ti.ToTitleCase( match.Groups[1].Value.ToLower() );
              else                                      return match.Groups[1].Value;
        }
开发者ID:Sukram21,项目名称:RegexRenamer,代码行数:10,代码来源:MainForm.cs

示例13: Page_Load


//.........这里部分代码省略.........
                {
                    command.CommandText = "SELECT " +
                        "Course_ID, " +
                        "Pic_File, " +
                        "Project_Name, " +
                        " Abstract, " +
                        "Live_Link, " +
                        "Video_Link, " +
                        "Proj_Zip_File, " +
                        "Proj_Pdf_File, " +
                        "Chair_Name, " +
                        "Chair_Email, " +
                        "Comm_Name, " +
                        "Comm_Email, " +
                        "Gadvisor_Name, " +
                        "Gadvisor_Email, " +
                        "Pres_Date " +
                        "FROM " +
                        "dbo.FILES " +
                        "WHERE username = @usernameDB";
                    command.Parameters.AddWithValue("@usernameDB", finalUsername);
                    try
                    {
                        connection.Open();
                        SqlDataReader reader = command.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                courseIDNumber = reader.GetString(0);
                                imageFile = reader.GetString(1);
                                researchName = reader.GetString(2);
                                abstractContent = reader.GetString(3);
                                liveLink = reader.GetString(4);
                                videoLink = reader.GetString(5);
                                zipFile = reader.GetString(6);
                                pdfFile = reader.GetString(7);
                                committeeChairName = reader.GetString(8);
                                committeeChairEmail = reader.GetString(9);
                                committeeMemberName = reader.GetString(10);
                                committeeMemberEmail = reader.GetString(11);
                                advisorName = reader.GetString(12);
                                advisorEmail = reader.GetString(13);
                                presentationDate = reader.GetString(14);

                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    finally
                    {
                        connection.Close();
                    }
                }
            }

            //Define object to make string proper case
            TextInfo titleCase = new CultureInfo("en-US", false).TextInfo;

            finalAdvisorName = titleCase.ToTitleCase(advisorName);
            finalCommitteeChairName = titleCase.ToTitleCase(committeeChairName);
            finalCommitteeMemberName = titleCase.ToTitleCase(committeeMemberName); 
            finalFirstName = titleCase.ToTitleCase(firstName.ToLower());
            finalLastName = titleCase.ToTitleCase(lastName);
            finalFullName = finalFirstName + " " + finalLastName;
            finalEmail = titleCase.ToLower(emailAddress);
            finalPicFile = imageFile;
            finalLiveLink = liveLink;
            finalVideoLink = videoLink;
            finalZipFile = zipFile;
            finalPdfFile = pdfFile;

            pdfLink.NavigateUrl = "UploadPDF\\" + finalPdfFile;
            zipLink.NavigateUrl = "UploadZIP\\" + finalZipFile; 

            userHeaderNameID.Text = finalFullName;
            profileNameID.Text = finalFullName;
            courseNumberID.Text = courseIDNumber;
            departmentID.Text = collegeDept;
            semesterCompletedID.Text = semesterCompleted;
            userEmailID.Text = finalEmail;
            researchNameLabel.Text = researchName;
            abstractID.Text = abstractContent;
            projectLiveLinkID.NavigateUrl = finalLiveLink;
            projectLiveLinkID.Text = finalLiveLink;
            projectVideoLinkID.NavigateUrl = finalVideoLink;
            projectVideoLinkID.Text = finalVideoLink;
            committeeChairNameID.Text = "Dr. "+finalCommitteeChairName;
            committeeChairEmailID.Text = committeeChairEmail;
            committeeMemberNameID.Text ="Dr. "+finalCommitteeMemberName;
            committeeMemberEmailID.Text = committeeMemberEmail;
            graduateAdvisorNameID.Text = finalAdvisorName;
            graduateAdvisorEmailID.Text = advisorEmail;
            presentationDateID.Text = presentationDate;

            userPic.InnerHtml = "<img class='userProfileImageBorder' src='UploadImage/" + finalPicFile + "'></img>";
        }
开发者ID:abhishek0066,项目名称:Reggi_Scholar_.NET_WebApplication,代码行数:101,代码来源:UserProfileReviewerApproval_Project.aspx.cs

示例14: ToTitleCase

 public static string ToTitleCase(this string s)
 {
     var textInfo = new CultureInfo("en-US", false).TextInfo;
     return textInfo.ToTitleCase(textInfo.ToLower(s));
 }
开发者ID:jasonracey,项目名称:iTunesAssistant,代码行数:5,代码来源:TitleCaser.cs

示例15: FormatMarketFactSourceDates

        public static string FormatMarketFactSourceDates(string strDate)
        {
            TextInfo myTI = new CultureInfo("en-US", false).TextInfo;
            string strFormatted = strDate;

            //REGULAR EXPRESSION MATCHES

            //Matches 3.24.02 => YYYY-MM-DD
            string re_mm_dd_yy = "^(?<Month>\\d{1,2})([./-])(?<Day>\\d{1,2})([./-])(?<Year>(?:\\d{1,2}))$";
            Regex objDatePattern1 = new Regex(re_mm_dd_yy, RegexOptions.None);
            if (objDatePattern1.IsMatch(strDate))
            {
                MatchCollection MatchArray = objDatePattern1.Matches(strDate);
                Match FirstMatch = MatchArray[0];
                string _year = FirstMatch.Groups["Year"].Value;
                string _month = FirstMatch.Groups["Month"].Value;
                string _day = FirstMatch.Groups["Day"].Value;

                Regex objIntPattern = new Regex("^\\d{1}$");
                if(objIntPattern.IsMatch(_month))
                {
                    _month = "0" + _month;
                };

                strFormatted = getYearFull(_year) + "-" + _month + "-" + _day;
            }

            //Matches SPRING 02 => Spring 2002
            string re_Season_yy = "^(?<Season>SPRING|SUMMER|FALL|WINTER)([\\s])(?<Year>\\d{1,2})$";
            Regex objDatePattern2 = new Regex(re_Season_yy, RegexOptions.None);
            if (objDatePattern2.IsMatch(strDate))
            {
                MatchCollection MatchArray = objDatePattern2.Matches(strDate);
                Match FirstMatch = MatchArray[0];
                string _season = myTI.ToLower(FirstMatch.Groups["Season"].Value);
                string _year = FirstMatch.Groups["Year"].Value;

                strFormatted = myTI.ToTitleCase(_season) + " " + getYearFull(_year);
            }

            //Matches 4.02 => April 2002
            string re_m_yy = "^(?<Month>\\d{1,2})([.])(?<Year>\\d{1,2})$";
            Regex objDatePattern3 = new Regex(re_m_yy, RegexOptions.None);
            if (objDatePattern3.IsMatch(strDate))
            {
                MatchCollection MatchArray = objDatePattern3.Matches(strDate);
                Match FirstMatch = MatchArray[0];
                string _month = FirstMatch.Groups["Month"].Value;
                string _year = FirstMatch.Groups["Year"].Value;

                strFormatted = getMonthFull(_month.TrimStart('0')) + " " + getYearFull(_year);
            }

            //Matches 1/2.02 => January/February 2002
            string re_M_M_yyyy = "^(?<Month>\\d{1,2})([/])(?<Month2>\\d{1,2})([.])(?<Year>\\d{1,2})$";
            Regex objDatePattern4 = new Regex(re_M_M_yyyy, RegexOptions.None);
            if (objDatePattern4.IsMatch(strDate))
            {
                MatchCollection MatchArray = objDatePattern4.Matches(strDate);
                Match FirstMatch = MatchArray[0];
                string _month = FirstMatch.Groups["Month"].Value;
                string _month2 = FirstMatch.Groups["Month2"].Value;
                string _year = FirstMatch.Groups["Year"].Value;

                strFormatted = getMonthFull(_month.TrimStart('0')) + "/" + getMonthFull(_month2.TrimStart('0')) + " " + getYearFull(_year);
            }

            //Matches 2001 => 2001
            string re_yyyy = "^(?<Year>\\d{4})$";
            Regex objDatePattern5 = new Regex(re_yyyy, RegexOptions.None);
            if (objDatePattern5.IsMatch(strDate))
            {
                MatchCollection MatchArray = objDatePattern5.Matches(strDate);
                Match FirstMatch = MatchArray[0];
                string _year = FirstMatch.Groups["Year"].Value;

                strFormatted = _year;
            }

            //Matches 6.28-7.4.02 => 28 June-4 July 2002
            string re_m_d_m_d_y = "^(?<Month>\\d{1,2})([.])(?<Day>\\d{1,2})([-])(?<Month2>\\d{1,2})([.])(?<Day2>\\d{1,2})([.])(?<Year>\\d{1,2})$";
            Regex objDatePattern6 = new Regex(re_m_d_m_d_y, RegexOptions.None);
            if (objDatePattern6.IsMatch(strDate))
            {
                MatchCollection MatchArray = objDatePattern6.Matches(strDate);
                Match FirstMatch = MatchArray[0];
                string _month = FirstMatch.Groups["Month"].Value;
                string _month2 = FirstMatch.Groups["Month2"].Value;
                string _day = FirstMatch.Groups["Day"].Value;
                string _day2 = FirstMatch.Groups["Day2"].Value;
                string _year = FirstMatch.Groups["Year"].Value;

                strFormatted = _day.TrimStart('0') + " " + getMonthFull(_month.TrimStart('0')) + "-" + _day2 + " " + getMonthFull(_day2.TrimStart('0')) + " " + getYearFull(_year);
            }


            //Matches 12.01/1.02 => December 2001/January 2002
            string re_mm_yy_mm_yy = "^(?<Month>\\d{1,2})([.])(?<Year>\\d{1,2})([/])(?<Month2>\\d{1,2})([.])(?<Year2>\\d{1,2})$";
            Regex objDatePattern7 = new Regex(re_mm_yy_mm_yy, RegexOptions.None);
            if (objDatePattern7.IsMatch(strDate))
//.........这里部分代码省略.........
开发者ID:IntertechInc,项目名称:.net-utilities,代码行数:101,代码来源:DateFormat.cs


注:本文中的System.Globalization.CultureInfo.ToLower方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。