c# - How to convert a string to uppercase characters

String ToUpper() Method
String represents text as a series of Unicode characters. String class ToUpper() method return a copy of string converted to uppercase. this method is overloaded, those are ToUpper() and ToUpper(CultureInfo).

string ToUpper() method is in System namespace and its return value type is string. that return 'string' is uppercase characters equivalent of the specified string. this ToUpper() method uses the casing rules of the current culture to convert each character to uppercase equivalent. the ToUpper() method does not modify the specified string instance, it just return a new string instance which all characters are converted to uppercase from specified string.

the string ToUpper(CultureInfo) method return a copy of the specified string converted to uppercase, using the casing rules of the specified culture.

the following .net c# example code demonstrate us how can we convert a string to uppercase characters in an asp.net application.
ToUpper.aspx

<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">
    protected void page_Load(object sender, System.EventArgs e) {
        if(!this.IsPostBack)
        {
            TextBox1.Text = "Click the button for change characters to uppercase.";
            TextBox1.Width = 450;
        }
    }
    protected void Button1_Click(object sender, System.EventArgs e) {
        string myString = TextBox1.Text.ToString();
        string modifiedString = myString.ToUpper();

        Label1.Text = "String converted successfully to upper case!";
        TextBox1.Text = modifiedString;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to convert (change) a string to uppercase characters in asp.net</title>
</head> 
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Navy">asp.net string example: ToUpper()</h2>
        <asp:Label 
             ID="Label1" 
             runat="server" 
             Font-Size="Large"
             ForeColor="Crimson"
             Font-Bold="true"
             Font-Italic="true"
             >
        </asp:Label>
        <br /><br />
        <asp:Label 
             ID="Label2" 
             runat="server" 
             Text="Test String"
             ForeColor="DarkCyan"
             >
        </asp:Label>
        <asp:TextBox 
             ID="TextBox1" 
             runat="server" 
             BackColor="DarkCyan" 
             ForeColor="Snow"
             >
        </asp:TextBox>
        <br /><br />
        <asp:Button 
             ID="Button1" 
             runat="server" 
             OnClick="Button1_Click"
             Font-Bold="true"
             Text="Change String To Uppercase"
             ForeColor="DarkCyan"
             />   
    </div>
    </form>
</body>
</html>
More c# examples