2008/05/12
C# – 判斷字串是否為數字
在C#要怎麼判斷字串是否為數字呢?
這個很常用,記起來。
public static bool IsNumber(string strNumber)
{
System.Text.RegularExpressions.Regex r=new System.Text.RegularExpressions.Regex(@"^\d+(\.)?\d*$");
return r.IsMatch(strNumber);
}


