Start learning free

LESSON 65 OF 674 · STRINGS I

Uppercase and Lowercase in C#

Lesson

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().

STEP 1 OF 2
    Ctrl + Enter to check