I see many people using regular expressions or other various algorithms. After a simple test, the following writing method should be more efficient
public static bool IsNum(string str)
{
for(int i=0;i<str.Length;i++)
{
if(str[i]<='0' || str[i]>='9')
return false;
}
return true;
}
Finally, the relevant regular expression is attached for everyone to verify. The reference regular expression: "^d+$"
In addition, if someone likes to use Char.IsNumber(), it can also be used, but this method has the advantage of being compatible with full-width, so the overall speed is not particularly good.