我有一个奇怪的问题,我正在使用下面的代码来测试一个电话号码,在我的测试中我的代码运行正常.该节目昨天上线,有人使用电话号码08720 123 456,我的代码失败了.你能告诉我为什么0161 287 1234会返回TRUE,08720 123 456会返回FALSE吗?
传真号码1:0161 287 1234 ---> IsNumber返回TRUE传真号码2:08720 123 456 ---> IsNumber返回FALSE
static bool IsNumber(string value)
{
// Return true if this is a number.
int number1;
return int.TryParse(value, out number1);
}
bool testForFax = IsNumber(faxOrEmail);
if (testForFax == true)
{
backgroundWorker2.RunWorkerAsync(); //send fax
}
else
{
MessageBox.Show("Please enter a fax number.");
}
Run Code Online (Sandbox Code Playgroud) c# ×1