Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Equivalent of isnumeric in C# 1

Status
Not open for further replies.

nnmmss72

Programmer
May 14, 2006
110
IR
i want to test whether a string is numeric or not. like the function of isnumeric in VB. i found this
Regex isNumeric = new Regex("[09]");
bool x = isNumeric.IsMatch(myString);
in

but i don't know how can i use Regex, which refenece should i use for that. i cann't access to it . and also i didn't find any help for that .i am using asp.net 1.0
 
The RegEx class is part of System.Text.RegularExpressions namespace.

Also, another method you may be able to use is Decimal.TryParse.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
ok i did az following

Regex isNumeric = new Regex("[09]");
bool x;

String tmpstr="5";
x = isNumeric.IsMatch(tmpstr);

but x is always false. what is wrong in my syntax?
 
sorry my mistake
it should be
Regex isNumeric = new Regex("[0-9]");
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top