C# String ToUpper(CultureInfo)

Description

String ToUpper(CultureInfo) returns a copy of this string converted to uppercase, using the casing rules of the specified culture.

Syntax

String.ToUpper(CultureInfo) has the following syntax.


public string ToUpper(
  CultureInfo culture
)

Parameters

String.ToUpper(CultureInfo) has the following parameters.

  • culture - An object that supplies culture-specific casing rules.

Returns

String.ToUpper(CultureInfo) method returns The uppercase equivalent of the current string.

Example

The following example converts a string of lowercase characters to two strings of uppercase characters using the English-United States and Turkish-Turkey cultures, then compares the uppercase strings.


using System;//from www  .  ja va2 s .  co m
using System.Globalization;

class Example 
{
    public static void Main() 
    {
       string str1 = "indigo";
       string str2, str3;

       // str2 is an uppercase copy of str1, using English-United States culture.
       str2 = str1.ToUpper(new CultureInfo("en-US", false));

       // str3 is an uppercase copy of str1, using Turkish-Turkey culture.
       str3 = str1.ToUpper(new CultureInfo("tr-TR", false));

       Console.WriteLine(str2);
       Console.WriteLine(str3);
    }
}

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