1 /// <summary> 2 /// 是否是Decimal,空返回false 3 /// </summary> 4 /// <param name="str"></param> 5 /// <returns></returns> 6 private bool IsDecimal(string s) 7 { 8 bool isDec = true; 9 try 10 { 11 Convert.ToDecimal(s); 12 } 13 catch 14 { 15 isDec = false; 16 } 17 18 return isDec; 19 20 } 21 22 /// <summary> 23 /// 是否是整数,空返回false 24 /// </summary> 25 /// <param name="str"></param> 26 /// <returns></returns> 27 public static bool IsInt(string str) 28 { 29 if (str == string.Empty) 30 return false; 31 try 32 { 33 Convert.ToInt32(str); 34 return true; 35 } 36 catch 37 { 38 return false; 39 } 40 } 41 42 //判读是否是日期 43 public bool IsDate(string strDate) 44 { 45 try 46 { 47 DateTime.Parse(strDate); 48 return true; 49 } 50 catch 51 { 52 return false; 53 } 54 } 55 56 57 58 //用正则表达式判断 59 //是否是数字 60 public static bool IsNumeric(string value) 61 { 62 return Regex.IsMatch(value, @"^[+-]?d*[.]?d*$"); 63 } 64 //是否是整数 65 public static bool IsInt(string value) 66 { 67 return Regex.IsMatch(value, @"^[+-]?d*$"); 68 }