/// <summary>
/// 判断字符串是否为数字
/// </summary>
public static bool IsNumber(string str)
{
if (string.IsNullOrWhiteSpace(str)) return false;
int icode;
foreach (char item in str)
{
icode = Convert.ToInt32(item);
if (icode < 48 || icode > 57)
{
return false;
}
}
return true;
}
OR
TryParse int.tryparse