Is char a digit

In this chapter you will learn:

  1. How to use Char.IsDigit to find out if a char is a digit

Char.IsDigit method

using System;  //j a v  a2  s  . c om
  
class MainClass {     
  public static void Main() {     
    string str = "This is a test. $23"; 
    int i; 
 
    for(i=0; i < str.Length; i++) { 
      Console.Write(str[i] + " is"); 
      if(Char.IsDigit(str[i])) 
        Console.Write(" digit"); 
 
      Console.WriteLine(); 
    } 
 
  }     
}

The code above generates the following result.

Next chapter...

What you will learn in the next chapter:

  1. How to find out if a char is a letter
Home » C# Tutorial » bool, char
bool
bool and if statement
bool value to string
Parse string to bool value
char type
char escape sequence
char case
Compare char value
char min/max value
Is char a digit
Is char a letter
Is char a symbol
Is char a Separator
Is char white space
Convert to char
UTF-16 Character