System.Text.RegularExpressions.Regex.IsMatch(string,@"^\d*$")
/**//// <summary> /// 驗(yàn)證是否是整數(shù) /// </summary> /// <param name="lstr">string</param> /// <returns>bool</returns> public static bool isNumberR(string lstr) ...{ string pat = @"^(d{1,9}$)"; Regex r=new Regex(pat,RegexOptions.Compiled); Match m=r.Match(lstr);
if(!m.Success) ...{ return false; } return true; }
/**//// <summary> ///驗(yàn)證是否是整數(shù) /// </summary> /// <param name="str">string</param> /// <returns>bool</returns> public static bool IsNum(string str) ...{ bool flag = true; try ...{ Int32.Parse(str); } catch(FormatException) ...{ flag = false; } return flag; }
|