helo
i want to check a string if it contains numeric values or not.
Plz help me in this regard as soon as possible.
Check a string for numeric values
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend3days leftRegister
Realgar22 pointsPosted Aug 17, 2005, 5:58 AM EDT
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;
}
}