这样判断了是不是数字,可是假如含有小数点的时候就会提示选择正确项了,该怎么修改才能使整数或小数都可以通过判断呢?
string temp = s[2];
for (int x = 0; x < temp.Length; x++)
{
byte tempByte = Convert.ToByte(temp[x]);//判断value能否为数字
if ((tempByte < 48) || (tempByte > 57))
{
MessageBox.Show("Please select the correct item!", "Prompt", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
}
}
解决方案
20
是Regex.IsMatch();