
ToUpper uppercases all letters in a string. It is useful for processing text input or for when you need to check the string against an already uppercase string. It has no effect on non-lowercase characters.

ToUpper is an instance method on the string type, which means you must have a string variable instance to call it. Here we see the ToUpper method, which works the same as ToLower except it changes lowercase characters to uppercase characters. You can use it just like ToLower.
This C# example program uses the ToUpper method. It demonstrates the output of ToUpper.
Program that uses ToUpper [C#]
using System;
using System.Globalization;
class Program
{
static void Main()
{
//
// Uppercase this mixed case string.
//
string value1 = "Lowercase string.";
string upper1 = value1.ToUpper();
Console.WriteLine(upper1);
//
// Uppercase this string.
//
string value2 = "R2D2";
string upper2 = value2.ToUpper(CultureInfo.InvariantCulture);
Console.WriteLine(upper2);
}
}
Output
(Second string is not changed.)
LOWERCASE STRING.
R2D2Description. The ToUpper instance method converts all the lowercase characters to uppercase characters, ignoring non-lowercase characters such as the uppercase 'L' and the period. The second part of the example tries to uppercase a string that is already uppercased; nothing is changed in the string.
Using CultureInfo. The CultureInfo.Invariant culture class specifies that you want the string to be uppercased the same way on all computers that might run your program. It is useful for larger programs or programs that will be sold.

Do you need to uppercase the first letter? If you do, then you should use ToCharArray and char.ToUpper, not the ToUpper instance method on string as we saw here.
Uppercase First Letter
In this example, we looked at the ToUpper instance method on string in the C# language. We saw that this method uppercases all letters in strings, and it leaves non-lowercase letters completely unchanged. Also, we touched on the invariant culture method and noted other uppercase solutions.
ToLower Method String Type