I mean :
1231 YES
121.1241 NO
121,1241 NO
-121 NO
124a NO
how can i do it faster in C#?
Python's isnumeric() function can be used to test whether a string is an integer or not. The isnumeric() is a builtin function. It returns True if all the characters are numeric, otherwise False.
function isInteger(num) { return (num ^ 0) === num; } console. log(isInteger(1));
isInteger() method returns true if a value is an integer of the datatype Number. Otherwise it returns false .
int x;
if (int.TryParse(str, out x) && x > 0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With