IsNumeric C# equivalent

  • Thread starter Thread starter Stephan Bour
  • Start date Start date
Actually, IsNumeric does two things: converts a string and returns a boolean
true if the resulting expression is recognized as a number. Parse only
converts a string representation of a number to double. I need the boolean
return to validate a text box entry that can't be easily checked with a
validator.
Stephan.
 
That's the idea. However, I need to do that on a string. I guess I could use
the String.ToCharArray() method first or use a loop.
Thanks,
Stephan.
 
I apologize, I read TryParse too fast. You're right, it does what I need.
Thank you,
Stephan.
 
So, check TryParse

MSDN:
The TryParse method is like the Parse method, except this method does not
throw an exception if the conversion fails. If the conversion succeeds, the
return value is true and the result parameter is set to the outcome of the
conversion. If the conversion fails, the return value is false and the
result parameter is set to zero.



HTH

Alex
 
Back
Top