Mohanapriya R Mohanapriya R
Updated date May 02, 2024
Explore a simple program demonstrating the use of the ToUpper method, and enhance your coding skills in text manipulation.

Converting Strings to Uppercase in C#

The primary method for converting a string to uppercase in C# is by using the ToUpper method. This method is available on the string class and returns a new string with all the characters converted to uppercase.

using System;

class Program
{
    static void Main()
    {
        // Input string
        string inputString = "Hello, World!";

        // Convert to uppercase
        string uppercaseString = inputString.ToUpper();

        // Output the result
        Console.WriteLine("Original String: " + inputString);
        Console.WriteLine("Uppercase String: " + uppercaseString);
    }
}

Output:

Original String: Hello, World!
Uppercase String: HELLO, WORLD!

In this example, the ToUpper method is applied to the inputString, resulting in a new string where all characters are in uppercase. The original string remains unchanged.

Comments (0)

There are no comments. Be the first to comment!!!