How to find if the character entered is Digit in C# ?

The Char class provides a method Char.IsDigit that lets you find if the character entered in the specid string is a digit or not.

How to find if the character entered is Digit in C# ?

Below is a sample code demonstrating the Char.IsDigit to find if the character entered is Digit in C#.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
    static class Program
    {
        static void Main()
        {
            FindCharacter();           
        }

        static void FindCharacter()
        {
            string str = "3a";
            foreach (var ch in str)
            {
                if (Char.IsDigit(ch))
                {
                    MessageBox.Show(ch.ToString() + " is a Digit");
                }
            }

        }
    }  
}
%d bloggers like this: