public static bool StrIsInt(string Str)
{
try
{
Int32.Parse(Str);
return true;
}
catch
{
bool flag = false;
return flag;
}
}
{
try
{
Int32.Parse(Str);
return true;
}
catch
{
bool flag = false;
return flag;
}
}
using System.Text.RegularExpressions; ......string str;......bool yn=Regex.IsMatch(str,@"^[0-9]+$");
if(yn==true)
{ MessageBox.Show("y"); //含有数字
}
else
{
MessageBox.Show("n"); //不含有数字}
建议楼主使用