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

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -