Export (0) Print
Expand All

TextInfo.ToUpper Method (Char)

Converts the specified character to uppercase.

Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)

public virtual char ToUpper (
	char c
)
public char ToUpper (
	char c
)
public function ToUpper (
	c : char
) : char
Not applicable.

Parameters

c

The character to convert to uppercase.

Return Value

The specified character converted to uppercase.

Casing semantics depend on the culture in use. For the invariant culture, the casing semantics are not culture-sensitive. For a specific culture, the casing semantics are sensitive to that culture.

If a security decision depends on a string comparison or a case-change operation, the application should use the InvariantCulture to ensure that the behavior is consistent regardless of the culture settings of the system. However, the invariant culture must be used only by processes that require culture-independent results, such as system services. Otherwise, it produces results that might be linguistically incorrect or culturally inappropriate.

For more information on cultures, see CultureInfo.

Windows Mobile 2003 for Pocket PC, Windows Mobile 2003 for Smartphone, Windows CE Platform Note: The .NET Compact Framework uses native Windows CE functions to change characters to upper or lower case. Windows CE does not provide changing the case of surrogate pairs, so this capability is not supported in the .NET Compact Framework.

The following code example changes the casing of a string based on the "en-US" culture.

using System;
using System.Globalization;


public class SamplesTextInfo  {

   public static void Main()  {

      // Defines the string with mixed casing.
      string myString = "wAr aNd pEaCe";

      // Creates a TextInfo based on the "en-US" culture.
      TextInfo myTI = new CultureInfo("en-US",false).TextInfo;

      // Changes a string to lowercase.
      Console.WriteLine( "\"{0}\" to lowercase: {1}", myString, myTI.ToLower( myString ) );

      // Changes a string to uppercase.
      Console.WriteLine( "\"{0}\" to uppercase: {1}", myString, myTI.ToUpper( myString ) );

      // Changes a string to titlecase.
      Console.WriteLine( "\"{0}\" to titlecase: {1}", myString, myTI.ToTitleCase( myString ) );

   }

}

/*
This code produces the following output.

"wAr aNd pEaCe" to lowercase: war and peace
"wAr aNd pEaCe" to uppercase: WAR AND PEACE
"wAr aNd pEaCe" to titlecase: War And Peace

*/

import System.*;
import System.Globalization.*;

public class SamplesTextInfo
{   
    public static void main(String[] args)
    {
        // Defines the string with mixed casing.
        String myString = "wAr aNd pEaCe";

        // Creates a TextInfo based on the "en-US" culture.
        TextInfo myTI = (new CultureInfo("en-US", false)).get_TextInfo();

        // Changes a string to lowercase.
        Console.WriteLine("\"{0}\" to lowercase: {1}", 
            myString, myTI.ToLower(myString));    

        // Changes a string to uppercase.
        Console.WriteLine("\"{0}\" to uppercase: {1}", 
            myString, myTI.ToUpper(myString));

        // Changes a string to titlecase.
        Console.WriteLine("\"{0}\" to titlecase: {1}", 
            myString, myTI.ToTitleCase(myString));
    } //main
} //SamplesTextInfo

/*
This code produces the following output.

"wAr aNd pEaCe" to lowercase: war and peace
"wAr aNd pEaCe" to uppercase: WAR AND PEACE
"wAr aNd pEaCe" to titlecase: War And Peace

*/

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show:
© 2015 Microsoft