0Pricing
C# Academy · Lesson

Char Helper Methods

IsDigit, IsLetter, ToUpper.

Char Helper Methods is a free C# Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the C# Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

The char Helper Methods

The char type comes with static helper methods that test or transform a character.

They live on the char type itself, so you call them like char.IsDigit(c). Most return a bool answering a yes or no question.

char c = '5';
bool isNumber = char.IsDigit(c);
// isNumber is true

char.IsDigit

char.IsDigit returns true when the character is a digit from 0 to 9.

This is great for checking user input before converting text into numbers.

class Program
{
    static void Main()
    {
        System.Console.WriteLine(char.IsDigit('8'));
        System.Console.WriteLine(char.IsDigit('x'));
    }
}

char.IsLetter

char.IsLetter returns true when the character is an alphabetic letter.

It works for both uppercase and lowercase letters, and it covers letters from many languages, not just English.

class Program
{
    static void Main()
    {
        System.Console.WriteLine(char.IsLetter('a'));
        System.Console.WriteLine(char.IsLetter('3'));
    }
}

char.IsLetterOrDigit

Sometimes you want to accept both letters and digits.

char.IsLetterOrDigit returns true if the character is either a letter or a digit. It is useful for validating identifiers or simple input.

bool a = char.IsLetterOrDigit('Q');
bool b = char.IsLetterOrDigit('!');
// a is true, b is false

char.IsWhiteSpace

char.IsWhiteSpace returns true for spaces, tabs, and newlines.

It helps you skip or trim blank characters when processing text.

class Program
{
    static void Main()
    {
        System.Console.WriteLine(char.IsWhiteSpace(' '));
        System.Console.WriteLine(char.IsWhiteSpace('A'));
    }
}

char.ToUpper

char.ToUpper returns the uppercase version of a character.

If the character is already uppercase or has no uppercase form, it is returned unchanged. Note the original value is not modified; a new char is returned.

class Program
{
    static void Main()
    {
        char upper = char.ToUpper('g');
        System.Console.WriteLine(upper);
    }
}

char.ToLower

char.ToLower returns the lowercase version of a character.

Together with char.ToUpper, it lets you compare letters without caring about case. For example, convert both to lowercase before comparing.

class Program
{
    static void Main()
    {
        char lower = char.ToLower('H');
        System.Console.WriteLine(lower);
    }
}

char.IsUpper and char.IsLower

char.IsUpper tells you if a letter is uppercase, and char.IsLower tells you if it is lowercase.

Both return false for characters that are not letters, like digits or symbols.

bool a = char.IsUpper('K');
bool b = char.IsLower('k');
// both are true

Combining Helpers

You can combine helpers to make decisions in code.

This program checks a character and prints a label describing what kind it is, using a simple chain of conditions.

class Program
{
    static void Main()
    {
        char c = '7';
        if (char.IsDigit(c))
            System.Console.WriteLine("digit");
        else if (char.IsLetter(c))
            System.Console.WriteLine("letter");
    }
}

Converting a Digit char to a Number

The char '5' is not the number 5. To get the numeric value, you can subtract '0'.

Because digits have consecutive codes, '5' - '0' equals 5. This is a common trick for parsing single digits.

class Program
{
    static void Main()
    {
        char c = '5';
        int value = c - '0';
        System.Console.WriteLine(value);
    }
}

Helpers Return New Values

The transform helpers like ToUpper and ToLower never change the original character.

They return a new char, so you must store the result. If you ignore the return value, nothing appears to happen.

char c = 'a';
char big = char.ToUpper(c);
// c is still 'a', big is 'A'

Quick Check

Test your understanding of char helper methods.

Recap

The char type offers static helpers for testing and transforming characters.

Use IsDigit, IsLetter, and IsWhiteSpace to check kinds, and ToUpper and ToLower to change case. Remember these return new values, and subtract '0' to turn a digit char into its number.

Frequently asked questions

Is the “Char Helper Methods” lesson free?

Yes — the full text of “Char Helper Methods” is free to read here on the web, and the C# Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the C# Academy course, upgrade to CoddyKit PRO.

What will I learn in “Char Helper Methods”?

IsDigit, IsLetter, ToUpper. You practise C# Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start C# Academy?

No prior experience is required. C# Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Char Helper Methods” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this C# Academy lesson?

Yes. Every C# Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. The char Type
  2. Char Helper Methods
  3. Iterating Over Strings
  4. Building Strings
← Back to C# Academy