日期:2014-05-20 浏览次数:20970 次
string str="2, ,12,31,27,54,0,,6,56,";
String[] array=str.Split(new String[1]{","},StringSplitOptions.RemoveEmptyEntries);
foreach(str s in array)
if(Convert.ToInt32(s)>50)
{
Console.WriteLine("大于50.")
Break;
}
static void Main(string[] args)
{
string str = "2, ,12,31,27,54,0,,6,56,";
String[] array = str.Split(new String[1] { "," }, StringSplitOptions.RemoveEmptyEntries);
List<int> arrayList = new List<int>();
foreach (string s in array)
if (s.Trim() != "")
arrayList.Add(Convert.ToInt32(s));
//搜索数组中是否有大于50的数字,前面将字符串按逗号分隔
if (arrayList.Where(r => r > 50).Count() > 0)
Console.WriteLine("error");
Console.ReadLine();
}
string value = "2, ,12,31,27,50,0,,6,50,";
MessageBox.Show(System.Text.RegularExpressions.Regex.IsMatch(value, "\\,[ ]*((5[1-9])
------解决方案--------------------