判断用户输入为数字函数
protected void button2_click(object sender, eventargs e)
{
//判断正整数
int j=0;
for (int i = 0; i < textbox1.text.length; i++)
{
if (char.isnumber(textbox1.text, i))//这个方法用来判断整数还可以,判断负数和小数就失效了
j++;
}
if (j == textbox1.text.length)
{
response.write("ok");
}
else
{ response.write ("no");}
}但是,出现负数或者小数的时候,以上方法失效,则,使用自定义功能函数
public bool isnumber( object obj)
{
bool result = true;
try
{
string str = obj.tostring();
double d ;
d = double.parse(str);
}
catch
{ //parse 函数进行转换,不成功则抛出异常
result = false;
}
return result;}
protected void button3_click1(object sender, eventargs e)
{
//判断数if (isnumber(textbox1.text))
{
response.write("是数字");
}
else
{ response.write("不是数字"); }
}
韩剧再婚皇后阿里云盘全集高清1080P资源链接-韩剧再婚皇后免费阿里云盘资源下载4K高清无删减版链接
poipiku网站如何打开-poipiku官网网页版访问入口
明日方舟:终末地-云游戏畅玩入口-明日方舟:终末地-网页版在线直连地址
poki在线小游戏网页版-poki免费游戏大全入口
poki游戏入口-点开即玩-poki游戏-在线免费畅玩
原神akt大佬资源viciNeko入口链接-原神akt大佬资源网页vicineko入口链接分享