How to Convert Lowercase to String in C#?
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. In C# the process is very simple when we use the built-in methods.
using System;
class Program
{
static void Main(string[] args)
{
// Input lowercase string
string lowercaseStr "hello, techiehook!";
// Convert to uppercase
string uppercaseStr = lowercaseString.ToUpper();
// Output the result
Console.WriteLine("Lowercase string: " + lowercaseStr);
Console.WriteLine("Uppercase string: " + uppercaseStr);
}
}
In this program, we have declared a lowercase string "hello, techiehook!". Then, we used the ToUpper()
method, which is a built-in function in C# for strings. This method converts all characters in the string to uppercase.
Output:
Lowercase string: hello, techiehook!
Uppercase string: HELLO, TECHIEHOOK!
Comments (0)