C# | ToUpper() Method - GeeksforGeeks

31 Jan, 2019
In C#, ToUpper() is a string method. It converts every characters to uppercase (if there an an uppercase version). If a character does not have an uppercase equivalent, it remains unchanged. For example, special symbols remain unchanged. This method can be overloaded by passing different type of arguments to it.
String.ToUpper() Method
String.ToUpper(CultureInfo) Method
This method is used to returns a copy of the current string converted to uppercase.
Syntax:
public string ToUpper();

Return Type: Its return the string value, which is the uppercase equivalent of the given string. The return type of this method is System.String.
Example:
Input : str  = "GeeksForGeeks"
        str.ToUpper()
Output: GEEKSFORGEEKS

Input : str  = "This is C# Program xsdd_$#%"
        str.ToUpper()
Output: THIS IS C# PROGRAM XSDD_$#%

Below example programs illustrate the ToUpper() Method
Example 1:// C# program to desmonstrate the // use of ToUpper() method using System;  class Program {      // Main Method    public static void Main()    {          // original string        string str1 = "GeeksForGeeks";          // string converted to Upper case        string upperstr1 = str1.ToUpper();          Console.WriteLine(upperstr1);    }}Output:GEEKSFORGEEKS

// C# program to desmonstrate the // use of ToUpper() method using System;  class Program {      // Main Method    public static void Main()    {          // original string        string str1 = "GeeksForGeeks";          // string converted to Upper case        string upperstr1 = str1.ToUpper();          Console.WriteLine(upperstr1);    }}
Output:
GEEKSFORGEEKS

Example 2:// C# program to desmonstrate the // use of ToUpper() method using System;  class Program {      // Main Method    public static void Main()    {        // original string        string str2 = "This is C# Program xsdd_$#%";          // string converted to Upper case        string upperstr2 = str2.ToUpper();          Console.WriteLine(upperstr2);    }}Output:THIS IS C# PROGRAM XSDD_$#%

// C# program to desmonstrate the // use of ToUpper() method using System;  class Program {      // Main Method    public static void Main()    {        // original string        string str2 = "This is C# Program xsdd_$#%";          // string converted to Upper case        string upperstr2 = str2.ToUpper();          Console.WriteLine(upperstr2);    }}
Output:
THIS IS C# PROGRAM XSDD_$#%

This method is used to return a copy of the current string converted to uppercase, using the casing rules of the specified culture.
Syntax:
public string ToUpper (System.Globalization.CultureInfo culture);

Parameter:
culture: It is the required object which supplies culture-specific casing rules.
Return Type: This method returns the uppercase equivalent of the current string of type System.String.
Exception: This method can give ArgumentNullException if the value of culture is null.
Example:
// C# program to desmonstrate the // use of ToUpper(CultureInfo) method using System;using System.Globalization;  class Program {      // Main Method    public static void Main()    {        // original string        string str2 = "This is C# Program xsdd_$#%";          // string converted to Uppercase by        // using English-United States culture        string upperstr2 = str2.ToUpper(new CultureInfo("en-US", false));          Console.WriteLine(upperstr2);    }}
Output:
THIS IS C# PROGRAM XSDD_$#%

Note: These methods will not modify the value of the current instance. Instead, these return a new string in which all characters in the current instance will convert to uppercase.
Reference: https://docs.microsoft.com/en-us/dotnet/api/system.string.toupper?view=netframework-4.7.2
CSharp-method
CSharp-string
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Method Overriding
C# Dictionary with examples
C# | Delegates
Difference between Ref and Out keywords in C#
Destructors in C#
Extension Method in C#
C# | Constructors
Introduction to .NET Framework
C# | Abstract Classes
C# | Class and Object