判断字符串中的数字(可以进行演变)
时间:2016-09-21 21:21:01
收藏:0
阅读:154
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; } }
原文:http://www.cnblogs.com/haimingkaifa/p/5894065.html
评论(0)