C# - 判斷字串是否為數字

在C#要怎麼判斷字串是否為數字呢?

這個很常用,記起來。



public static bool IsNumber(string strNumber)
{
System.Text.RegularExpressions.Regex r=new System.Text.RegularExpressions.Regex(@"^\d+(\.)?\d*$");
return r.IsMatch(strNumber);
}

HEMiDEMi Technorati Del.icio.us MyShare個人書籤 Yahoo

張貼者:Paddy 於 晚上7:20  

1 意見:

上了一課,謝謝

張貼留言