In a C# 2010 application I would like to see if the value in the following is numeric:
strPID.Substring(3, 8).
Thus can you tell me how to see if the value in the substring starting at position 3 for a length of 8 is numeric?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Sep 12, 2012, 2:42 PM
string s = strPID.Substring(3, 8);
double d;
if (Double.TryParse(s, out d))
{
// it's numeric and value contained in 'd'
}
else
{
// it's not numeric and value of 'd' is 0
}