VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/c-sharp-toupper-method/

⇱ C# String ToUpper() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C# String ToUpper() Method

Last Updated : 11 Jul, 2025

In C#, the ToUpper() method is used to convert all characters in a string to uppercase. If a character has an uppercase letter, it is converted, otherwise, it remains unchanged. Special characters and symbols are unaffected. This method is commonly used for case-insensitive comparisons and text formatting.

Example 1: Basic Usage of ToUpper() Method


Output
String Before Conversion: GeeksForGeeks
String After Conversion: GEEKSFORGEEKS

Explanation: In this example, the ToUpper() method converts all lowercase letters in the string "GeeksForGeeks" to uppercase, resulting in "GEEKSFORGEEKS"

Syntax of String ToUpper() Method

public string ToUpper();

public string ToUpper(System.Globalization.CultureInfo culture);

  • Parameters: culture (optional): A CultureInfo object that defines culture-specific casing rules.
  • Return Type: The method returns a new string in which all characters have been converted to uppercase.

Example 2: Using String.ToUpper()


Output
THIS IS C# PROGRAM XSDD_$#%

Explanation: In this example, all alphabetic characters in the string are converted to uppercase, while special characters remain unchanged.


Example 3: Using String.ToUpper(CultureInfo)


Output
THIS IS C# PROGRAM XSDD_$#%

Explanation: In this example, the ToUpper(CultureInfo) method allows specifying a culture for case conversion. It ensures the consistency across different language settings.

Notes

  • The ToUpper() method does not modify the original string, it returns a new uppercase string.
  • If the CultureInfo parameter is null, an ArgumentNullException is thrown.
  • This method is useful for case-insensitive operations, such as string comparisons.
Comment
Article Tags:

Explore