C# Tutorial C# Advanced C# References

C# String - ToUpperInvariant() Method



The C# ToUpperInvariant() method returns the string with all characters of the specified string in uppercase using the casing rules of the invariant culture. Any symbol, space, special character or number in the string is ignored while applying this method. Only Alphabets are converted.

Syntax

public string ToUpperInvariant();

Parameters

No parameter is required.

Return Value

Returns the string with all characters of the specified string in uppercase using the casing rules of the invariant culture.

Exception

NA.

Example:

In the example below, ToUpperInvariant() method returns a string containing all characters of the specified string array called MyStr in uppercase using the casing rules of the invariant culture.

using System;

class MyProgram {
  static void Main(string[] args) {
    string[] MyStr = {"Hello", "Здравейте", "Szia", 
                   "Halló", "ਸਤ ਸ੍ਰੀ ਅਕਾਲ", "नमस्कार"};
    
    foreach (string str in MyStr)
      Console.WriteLine(str.ToUpperInvariant()); 
  }
}

The output of the above code will be:

HELLO
ЗДРАВЕЙТЕ
SZIA
HALLÓ
ਸਤ ਸ੍ਰੀ ਅਕਾਲ
नमस्कार

❮ C# String Methods