How to determines whether a character is a digit in C#

2 Answers

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {

            char ch = '9';

            if (Char.IsNumber(ch))
                Console.WriteLine("yes");
            else
                Console.WriteLine("no");

            ch = 'a';

            if (Char.IsNumber(ch))
                Console.WriteLine("yes");
            else
                Console.WriteLine("no");
        }
    }
}


/*
run:
    
yes
no

*/

 



answered Dec 5, 2016 by avibootz
0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {

            char ch = '9';

            if (Char.IsDigit(ch))
                Console.WriteLine("yes");
            else
                Console.WriteLine("no");

            ch = 'a';

            if (Char.IsDigit(ch))
                Console.WriteLine("yes");
            else
                Console.WriteLine("no");
        }
    }
}


/*
run:
    
yes
no

*/

 



answered Dec 5, 2016 by avibootz

Related questions

1 answer 198 views
1 answer 103 views
1 answer 169 views
1 answer 151 views
1 answer 160 views
1 answer 180 views
1 answer 177 views
...