How to determines if a character in the string is a digit in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            string s = "c# 987";

            foreach (char ch in s)
            {
                bool b = char.IsDigit(ch);

                Console.Write(ch);
                Console.Write(' ');
                Console.WriteLine(b);
            }
        }
    }
}


/*
run:
 
c False
# False
  False
9 True
8 True
7 True
  
*/

 



answered Jan 31, 2017 by avibootz

Related questions

1 answer 198 views
2 answers 138 views
1 answer 169 views
1 answer 151 views
1 answer 160 views
1 answer 180 views
1 answer 177 views
...