Mohanapriya R Mohanapriya R
Updated date May 09, 2024
In this article, we will learn the ins and outs of converting strings to lowercase in C#. Explore the simple yet powerful ToLower() method.

Converting Strings to Lowercase in C#:

In C#, the ToLower() method can be used to convert strings to lowercase. This method is part of the string class and returns a new string with all characters converted to lowercase. Let's take a look at a simple C# program that demonstrates this process:

using System;

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

        // Convert the string to lowercase
        string lowercaseString = originalString.ToLower();

        // Output the results
        Console.WriteLine("Original String: " + originalString);
        Console.WriteLine("Lowercase String: " + lowercaseString);
    }
}

Output:

Original String: Hello, World!
Lowercase String: hello, world!

In the program above, we start with an original string "Hello, World!". We then use the ToLower() method to convert this string to lowercase, and the result is stored in the lowercaseString variable. Finally, we output both the original and lowercase strings to the console.

Comments (0)

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