Mohanapriya R Mohanapriya R
Updated date Feb 15, 2024
In this article, we will learn how to convert lowercase strings to uppercase in C#. Explore a simple program example with output to understand the process effortlessly.

Converting Lowercase to String in C#

In C#, converting a lowercase string to uppercase is a common task, especially when dealing with user input or manipulating text data. Fortunately, C# provides straightforward methods to accomplish this task effortlessly. In this article, we will explore how to convert a lowercase string to uppercase using C#.

To begin, let's understand the basic concept behind converting lowercase to uppercase. In programming, uppercase letters have different ASCII values than their lowercase counterparts. Therefore, converting a lowercase letter to uppercase involves subtracting a specific value from its ASCII code. C# simplifies this process with built-in methods, making it easy for developers.

Without further ado, let's dive into the practical implementation of converting a lowercase string to uppercase in C#. Below is a simple C# program that demonstrates this process:

using System;

class Program
{
    static void Main(string[] args)
    {
        // Input lowercase string
        string lowercaseString = "hello, world!";

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

        // Output the result
        Console.WriteLine("Lowercase string: " + lowercaseString);
        Console.WriteLine("Uppercase string: " + uppercaseString);
    }
}

In this program, we first declare a lowercase string "hello, world!". Then, we use the ToUpper() method, which is a built-in function in C# for strings. This method converts all characters in the string to uppercase. Finally, we print both the original lowercase string and the converted uppercase string to the console.

Now, let's run this program and see the output:

Lowercase string: hello, world!
Uppercase string: HELLO, WORLD!

As we can see from the output, the lowercase string "hello, world!" has been successfully converted to uppercase, resulting in "HELLO, WORLD!".

In conclusion, converting a lowercase string to uppercase in C# is a straightforward process thanks to the built-in ToUpper() method. By following the example provided in this article, beginners can easily understand and implement this functionality in their C# projects.

Comments (0)

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