C# Char ToUpper(Char)

Description

Char ToUpper(Char) converts the value of a Unicode character to its uppercase equivalent.

Syntax

Char.ToUpper(Char) has the following syntax.


public static char ToUpper(
  char c
)

Parameters

Char.ToUpper(Char) has the following parameters.

  • c - The Unicode character to convert.

Returns

Char.ToUpper(Char) method returns The uppercase equivalent of c, 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.


//  www  . ja v a2 s.co m
using System;

public class Example
{
   public static void Main()
   {
      char[] chars = { 'a', 'E', '6' };
      foreach (var ch in chars)
          Console.WriteLine("{0} --> {1} {2}", ch, Char.ToUpper(ch),
                            ch == Char.ToUpper(ch) ? "(Same Character)" : "" );
   }
}

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