make a string upper case in csharp

To convert a string to upper case in C#, you can use the ToUpper() method from the String class. Here's an example:

main.cs
string myString = "Hello, World!";
string upperCaseString = myString.ToUpper();

Console.WriteLine(upperCaseString);
117 chars
5 lines

This will output HELLO, WORLD!. The ToUpper() method converts all characters in the string to their uppercase equivalent.

Note that the original string myString remains unchanged, and the converted string is assigned to upperCaseString.

Remember to include the using System; statement at the beginning of your code to use the Console.WriteLine() method.

related categories

gistlibby LogSnag