helo
i want to check a string if it contains numeric values or not.
Plz help me in this regard as soon as possible.
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.
RealgarPosted Aug 17, 2005, 9:58 AM
public static bool CheckForNumeric (string stringtocheck)
{
for (int i=0; i
if (char.isNumber(stringtocheck[i]))
return true;
}
return false;
}
this will return true if there is a number in the string...
if you want to check if a string is fully numeric then :
public static bool IsNumeric (string stringtocheck)
{
try
{
double number = double.Parse(stringtocheck);
return true;
}
catch
{
return false;
}
}