1、用正规式
using System.Text.RegularExpressions;
string pattern = @"^\d+(\.\d)?$";
if(Text1.Text.Trim()!=)
{
if(!Regex.IsMatch(Text1.Text.Trim(),pattern))
{
Text1不是数字;
}
else
{
Text1是数字;
}
}
--------------------------------------------------------------------
2、用异常
try
{
double.Parse(this.TextBox1.Text);
Response.Write(是数字);
}
catch
{
Response.Write(不是数字);
}
转载于:https://blog.51cto.com/myitworld/499321