110,534
社区成员
发帖
与我相关
我的任务
分享
public bool Isdigit(string str)
{
char[] temp = str.ToCharArray();
foreach (char cr in temp)
{
if (!char.IsDigit(cr))
{
return false;
}
}
return ture;
}
public bool Isdigit(string str)
{
char[] temp = str.ToCharArray();
foreach (char cr in temp)
{
if (!char.IsDigit(cr))
{
MessageBox.Show(cr.ToString()+"is not a digit");
}
}
}
private void txt_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == (char)Keys.Back || e.KeyChar == (char)Keys.Enter))
{
e.Handled = true;
}
}