![]() |
VOOZH | about |
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
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"
public string ToUpper();
public string ToUpper(System.Globalization.CultureInfo culture);
Example 2: Using String.ToUpper()
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)
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: