首页 > 代码库 > 判断字符串中的数字(可以进行演变)

判断字符串中的数字(可以进行演变)

技术分享
  static void Main(string[] args)        {            Console.WriteLine("请输入一个字符串:");           string str= Console.ReadLine();           Console.WriteLine("\n");           for (int i = 0; i < str.Length; i++)           {                            string n=  str.Substring(i, 1);               bool b =Number.GetNumber(n);               if (b ==true)               {                   //Console.WriteLine(n+",");                   Console.Write(n+",");               }           }                        Console.ReadKey();        }    }  public   class Number    {        public static bool GetNumber(string str)        {            bool b = false;            string[] arryList = { "0","1","2","3","4","5","6","7","8","9"};            foreach (string item in arryList)            {                if (item == str)                {                    b = true;                    break;                }                           }            return b;          }    }
View Code

 

判断字符串中的数字(可以进行演变)