服務(wù)熱線
153 8323 9821
try
{
double.Parse(this.TextBox1.Text);
Response.Write(是數(shù)字);
}
catch
{
Response.Write(不是數(shù)字);
}
這個用的比較多。。。。
以下是我判斷一個字符串是否為某一數(shù)據(jù)類型,
你可以寫個類,或者靜態(tài)函數(shù),用于判斷某個值是否是數(shù)字!
public static bool IsInt(Object value)
{
if (value == null)
return false;
try
{
int intValue = Convert.ToInt32(value);
return true;
}
catch (Exception ex)
{
return false;
}
}
如果看不懂正則表達(dá)式 用這樣的方法也就解決了