C# Char ToUpper(Char, CultureInfo)

Description

Char ToUpper(Char, CultureInfo) converts the value of a specified Unicode character to its uppercase equivalent using specified culture-specific formatting information.

Syntax

Char.ToUpper(Char, CultureInfo) has the following syntax.


public static char ToUpper(
  char c,
  CultureInfo culture
)

Parameters

Char.ToUpper(Char, CultureInfo) has the following parameters.

  • c - The Unicode character to convert.
  • culture - An object that supplies culture-specific casing rules.

Returns

Char.ToUpper(Char, CultureInfo) method returns The uppercase equivalent of c, modified according to culture, or the unchanged value of c if c is already uppercase, has no uppercase equivalent, or is not alphabetic.

Example

The following example converts each character in an array to its uppercase equivalent for the en-US culture, the invariant culture, and the tr-TR culture.


using System;//from  w ww. j  a  v a  2  s  . co m
using System.Globalization;

public class Example
{
   public static void Main()
   {
      CultureInfo[] cultures= { CultureInfo.CreateSpecificCulture("en-US"), 
                                CultureInfo.InvariantCulture, 
                                CultureInfo.CreateSpecificCulture("tr-TR") };
      Char[] chars = {'e', 'E', 'i', 'I' };

      Console.WriteLine("Character     en-US     Invariant     tr-TR");
      foreach (var ch in chars) {
         Console.Write("    {0}", ch);
         foreach (var culture in cultures) 
            Console.Write("{0,12}", Char.ToUpper(ch, culture));

         Console.WriteLine();
      }   
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version