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(不是数字);
}

--------------------------------------------------------------
3、用控件
C#中有个只能输入数字的控件NumericUpDown,你可以使用它。

相关文章:

  • 2022-12-23
  • 2022-01-25
  • 2022-12-23
  • 2022-12-23
  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-11
  • 2022-01-15
相关资源
相似解决方案