How to convert Lower case to Upper Case using C#?

To convert lowercase to uppercase in C#, use the ToUpper() method. This method converts all lowercase characters in a string to their uppercase equivalents and returns a new string without modifying the original string.

Syntax

Following is the syntax for the ToUpper() method −

string.ToUpper()
string.ToUpper(CultureInfo)

Parameters

  • CultureInfo (optional) − Specifies the culture-specific formatting information. If not provided, the current culture is used.

Return Value

The ToUpper() method returns a new string with all lowercase characters converted to uppercase. The original string remains unchanged.

Using ToUpper() Method

Example

using System;

class MyApplication {
    static void Main(string[] args) {
        string str = "david";
        Console.WriteLine("LowerCase : {0}", str);
        
        // convert to uppercase
        Console.WriteLine("Converted to UpperCase : {0}", str.ToUpper());
        
        // original string remains unchanged
        Console.WriteLine("Original string : {0}", str);
    }
}

The output of the above code is −

LowerCase : david
Converted to UpperCase : DAVID
Original string : david

Using ToUpper() with Mixed Case Strings

Example

using System;

class Program {
    static void Main(string[] args) {
        string mixedCase = "Hello World! 123";
        string upperCase = mixedCase.ToUpper();
        
        Console.WriteLine("Original: " + mixedCase);
        Console.WriteLine("Upper Case: " + upperCase);
        
        // ToUpper() also works with special characters
        string special = "welcome@2024!";
        Console.WriteLine("Special chars: " + special.ToUpper());
    }
}

The output of the above code is −

Original: Hello World! 123
Upper Case: HELLO WORLD! 123
Special chars: WELCOME@2024!

Using Culture-Specific ToUpper()

Example

using System;
using System.Globalization;

class Program {
    static void Main(string[] args) {
        string text = "istanbul";
        
        // Using invariant culture
        string invariant = text.ToUpper(CultureInfo.InvariantCulture);
        Console.WriteLine("Invariant Culture: " + invariant);
        
        // Using Turkish culture (different handling of 'i')
        string turkish = text.ToUpper(new CultureInfo("tr-TR"));
        Console.WriteLine("Turkish Culture: " + turkish);
        
        // Using current culture
        string current = text.ToUpper();
        Console.WriteLine("Current Culture: " + current);
    }
}

The output of the above code is −

Invariant Culture: ISTANBUL
Turkish Culture: ?STANBUL
Current Culture: ISTANBUL

Conclusion

The ToUpper() method in C# converts all lowercase characters in a string to uppercase and returns a new string. It supports culture-specific formatting and leaves the original string unchanged, making it safe for string manipulation operations.

Updated on: 2026-03-17T07:04:35+05:30

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements