Facebook Page Twitter Page LinkedIn Page
× C# Tutorial C# Advanced C# Resources


The C# string ToUpperInvariant() method is used to return 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 below example, ToUpperInvariant() method to used to return 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