The Char.IsDigit() method in C# indicates whether the specified Unicode character is categorized as a decimal digit.
Syntax
Following is the syntax −
public static bool IsDigit (char ch);
Above, the parameter ch is the Unicode character to evaluate.
Example
Let us now see an example to implement the Char.IsDigit() method −
using System;
public class Demo {
public static void Main(){
bool res;
char val = 'g';
Console.WriteLine("Value = "+val);
res = Char.IsDigit(val);
Console.WriteLine("Is the value a digit? = "+res);
}
}Output
This will produce the following output −
Value = g Is the value a digit? = False
Example
Let us now see another example −
using System;
public class Demo {
public static void Main(){
bool res;
char val = '2';
Console.WriteLine("Value = "+val);
res = Char.IsDigit(val);
Console.WriteLine("Is the value a digit? = "+res);
}
}Output
This will produce the following output −
Value = 2 Is the value a digit? = True