c# - check if the first element of a string is positive integer -
c# - check if the first element of a string is positive integer -
i need check if first element of string positive integer in c#. there smart way this? fx
string str = "2001"; if (str.first() == isanumber) { ... }
you can seek this:
string s = "1sdfa"; bool isdigit = char.isdigit(s[0]);
also, if wanted additional checks on string, them this:
bool isdigit = !string.isnullorempty(s) && char.isdigit(s[0]);
c# string parsing
Comments
Post a Comment