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


C# CultureInfo.ToUpper方法代码示例

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


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

示例1: PosTest2

    public bool PosTest2()
    {
        bool retVal = true;
        string strA = string.Empty;
        string ActualResult;

        TextInfo textInfo = new CultureInfo("en-US").TextInfo;


        TestLibrary.TestFramework.BeginScenario("PosTest2: empty string ToUpper");
        try
        {
            ActualResult = textInfo.ToUpper(strA);
            if (ActualResult != string.Empty)
            {
                TestLibrary.TestFramework.LogError("003", "empty string ToUpper ActualResult is not the ExpectResult");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception:" + e);
            retVal = false;
        }
        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:26,代码来源:textinfotoupper2.cs

示例2: PosTest1

    public bool PosTest1()
    {
        bool retVal = true;
        string strA = "HelloWorld!";
        string ActualResult;

        TextInfo textInfo = new CultureInfo("en-US").TextInfo;

        TestLibrary.TestFramework.BeginScenario("PosTest1: normal string ToUpper");
        try
        {   
            ActualResult = textInfo.ToUpper(strA);
            if (ActualResult != "HELLOWORLD!")
            {
                TestLibrary.TestFramework.LogError("001", "normal string ToUpper ActualResult is not the ExpectResult");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception:" + e);
            retVal = false;
        }
        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:25,代码来源:textinfotoupper2.cs

示例3: PosTest1

    public bool PosTest1()
    {
        bool retVal = true;

        const string c_TEST_ID = "P001";
        const string c_TEST_DESC = "PosTest1: uppercase character";
        string errorDesc;

        char ch = 'A';
        char expectedChar = ch;
        TextInfo textInfo = new CultureInfo("en-US").TextInfo;


        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
        try
        {
           
            char actualChar = textInfo.ToUpper(ch);
            if (actualChar != expectedChar)
            {
                errorDesc = string.Format("Uppercase of character \\u{0:x} is not the value ", (int)ch);
                errorDesc += string.Format("\\u{0:x} as expected: actual(\\u{1:x}", (int)expectedChar, (int)actualChar);
                TestLibrary.TestFramework.LogError("001" + " TestId-" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            errorDesc = "Unexpected exception: " + e;
            TestLibrary.TestFramework.LogError("002" + " TestId-" + c_TEST_ID, errorDesc);
            retVal = false;
        }

        return retVal;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:35,代码来源:textinfotoupper1.cs

示例4: EnUsPosixIsNotATurkishCasingLocale

    public static void EnUsPosixIsNotATurkishCasingLocale()
    {
        // ICU has special tailoring for the en-US-POSIX locale which treats "i" and "I" as different letters
        // instead of two letters with a case difference during collation.  Make sure this doesn't confuse our
        // casing implementation, which uses collation to understand if we need to do turkish casing or not.

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

        Assert.Equal('I', ti.ToUpper('i'));
        Assert.Equal('i', ti.ToLower('I'));
    }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:11,代码来源:TextInfo.cs

示例5: ToUpper

    public static void ToUpper(string localeName)
    {
        TextInfo ti = new CultureInfo(localeName).TextInfo;

        Assert.Equal('A', ti.ToUpper('a'));
        Assert.Equal("ABC", ti.ToUpper("abc"));
        Assert.Equal('A', ti.ToUpper('A'));
        Assert.Equal("ABC", ti.ToUpper("ABC"));

        Assert.Equal("THIS IS A LONGER TEST CASE", ti.ToUpper("this is a longer test case"));
        Assert.Equal("THIS IS A LONGER MIXED CASE TEST CASE", ti.ToUpper("this Is A LONGER mIXEd casE test case"));

        Assert.Equal("THIS \t HAS \t SOME \t TABS", ti.ToUpper("this \t HaS \t somE \t TABS"));

        Assert.Equal('1', ti.ToUpper('1'));
        Assert.Equal("123", ti.ToUpper("123"));

        Assert.Equal("EMBEDDED\0NULL\0BYTE\0", ti.ToUpper("embedded\0NuLL\0Byte\0"));

        // LATIN SMALL LETTER O WITH ACUTE, which has an upper case variant.
        Assert.Equal('\u00D3', ti.ToUpper('\u00F3'));
        Assert.Equal("\u00D3", ti.ToUpper("\u00F3"));

        // SNOWMAN, which does not have an upper case variant.
        Assert.Equal('\u2603', ti.ToUpper('\u2603'));
        Assert.Equal("\u2603", ti.ToUpper("\u2603"));

        // DESERT SMALL LETTER LONG I has an upperc case variant.
        Assert.Equal("\U00010400", ti.ToUpper("\U00010428"));

        // RAINBOW (outside the BMP and does not case)
        Assert.Equal("\U0001F308", ti.ToLower("\U0001F308"));

        // These are cases where we have invalid UTF-16 in a string (mismatched surrogate pairs).  They should be
        // unchanged by casing.
        Assert.Equal("BE CAREFUL, \uD83C\uD83C, THIS ONE IS TRICKY", ti.ToUpper("be careful, \uD83C\uD83C, this one is tricky"));
        Assert.Equal("BE CAREFUL, \uDF08\uD83C, THIS ONE IS TRICKY", ti.ToUpper("be careful, \uDF08\uD83C, this one is tricky"));
        Assert.Equal("BE CAREFUL, \uDF08\uDF08, THIS ONE IS TRICKY", ti.ToUpper("be careful, \uDF08\uDF08, this one is tricky"));

        Assert.Throws<ArgumentNullException>(() => ti.ToUpper(null));
    }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:41,代码来源:TextInfo.cs

示例6: NoUnicodeSpecialCases

    public static void NoUnicodeSpecialCases(string localeName)
    {
        // Unicode defines some codepoints which expand into multiple codepoints
        // when cased (see SpecialCasing.txt from UNIDATA for some examples).  We have never done
        // these sorts of expansions, since it would cause string lengths to change when cased,
        // which is non-intuative.  In addition, there are some context sensitive mappings which
        // we also don't preform.
        
        TextInfo ti = new CultureInfo(localeName).TextInfo;

        // es-zed does not case to SS when upercased.
        Assert.Equal("\u00DF", ti.ToUpper("\u00DF"));

        // Ligatures do not expand when cased.
        Assert.Equal("\uFB00", ti.ToUpper("\uFB00"));

        // Precomposed character with no uppercase variaint, we don't want to "decompose" this
        // as part of casing.
        Assert.Equal("\u0149", ti.ToUpper("\u0149"));

        // Greek Capital Letter Sigma (does not to case to U+03C2 with "final sigma" rule).
        Assert.Equal("\u03C3", ti.ToLower("\u03A3"));
    }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:23,代码来源:TextInfo.cs

示例7: TurkishICasing

    public static void TurkishICasing(string localeName)
    {
        TextInfo ti = new CultureInfo(localeName).TextInfo;

        Assert.Equal('i', ti.ToLower('\u0130'));
        Assert.Equal("i", ti.ToLower("\u0130"));

        Assert.Equal('\u0130', ti.ToUpper('i'));
        Assert.Equal("\u0130", ti.ToUpper("i"));

        Assert.Equal('\u0131', ti.ToLower('I'));
        Assert.Equal("\u0131", ti.ToLower("I"));

        Assert.Equal('I', ti.ToUpper('\u0131'));
        Assert.Equal("I", ti.ToUpper("\u0131"));
    }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:16,代码来源:TextInfo.cs

示例8: NegTest2

    public bool NegTest2()
    {
        bool retVal = true;

        const string c_TEST_DESC = "NegTest2: The string is a null reference and TextInfo is French (France) CultureInfo's";
        const string c_TEST_ID = "N001";

        TextInfo textInfoUS = new CultureInfo("fr-FR").TextInfo;
        string str = null;

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        try
        {
            textInfoUS.ToUpper(str);
            TestLibrary.TestFramework.LogError("011" + " TestId-" + c_TEST_ID, "ArgumentNullException is not thrown as expected.");
            retVal = false;
        }
        catch (ArgumentNullException)
        {
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("012" + " TestId-" + c_TEST_ID, "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:29,代码来源:textinfotoupper2.cs

示例9: PosTest6

    public bool PosTest6()
    {
        bool retVal = true;
        string strA = "Hello\n\0World\u0009!";
        string ActualResult;

        TextInfo textInfo = new CultureInfo("fr-FR").TextInfo;

        TestLibrary.TestFramework.BeginScenario("PosTest6: normal string with special symbols and TextInfo is French (France) CultureInfo's");
        try
        {

            ActualResult = textInfo.ToUpper(strA);
            if (ActualResult != "HELLO\n\0WORLD\t!")
            {
                TestLibrary.TestFramework.LogError("011", "normal string with special symbols ToUpper ActualResult is not the ExpectResult");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("012", "Unexpected exception:" + e);
            retVal = false;
        }
        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:26,代码来源:textinfotoupper2.cs

示例10: PosTest3

    public bool PosTest3()
    {
        bool retVal = true;

        const string c_TEST_ID = "P003";
        const string c_TEST_DESC = "PosTest3: non-alphabetic character";
        string errorDesc;

        char ch = Convert.ToChar(TestLibrary.Generator.GetInt16(-55) % 10 + '0');
        char expectedChar = ch;
        TextInfo textInfo = new CultureInfo("en-US").TextInfo;

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
        try
        {
            
            char actualChar = textInfo.ToUpper(ch);
            if (actualChar != expectedChar)
            {
                errorDesc = string.Format("Uppercase of character \\u{0:x} is not the value ", (int)ch);
                errorDesc += string.Format("\\u{0:x} as expected: actual(\\u{1:x}", (int)expectedChar, (int)actualChar);
                TestLibrary.TestFramework.LogError("005" + " TestId-" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            errorDesc = "Unexpected exception: " + e;
            TestLibrary.TestFramework.LogError("006" + " TestId-" + c_TEST_ID, errorDesc);
            retVal = false;
        }

        return retVal;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:34,代码来源:textinfotoupper1.cs


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