You have to write like these:
private bool isNumber(string str)
{
try{
int.Parse(str);
}
catch{
return false;
}
return true;
}Hope it could be help
private bool isNumber(string str)
{
try{
int.Parse(str);
}
catch{
return false;
}
return true;
}Hope it could be help
而string中并无此方法.
不知道还有没有更好的办法,请大家发表下意见.
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if(!char.IsDigit(e.KeyChar))
e.Handled = true;
}
public bool isNumberic(string strTemp)
{
for(int i=0;i<strTemp.Length;i++)
{
if(!char.IsDigit(strTemp[i]))
return false;
}
return true;
}