In C#, string objects have built-in methods to change their case:
s.ToUpper() // converts all characters to uppercase
s.ToLower() // converts all characters to lowercase
Here are some examples:
string word = "Hello World";
string upper = word.ToUpper(); // "HELLO WORLD"
string lower = word.ToLower(); // "hello world"
string name = "ALICE";
Console.WriteLine(name.ToLower()); // "alice"
These methods return a new string — the original is not modified.
Assignment
Follow the Coding Tutorial and convert word to both uppercase and lowercase!
Hint
Use word.ToUpper() and word.ToLower().
Free plan: 30 tutor messages. PRO is unlimited.
Saved
Ctrl + Enter to check
