Code, .NETNovember 7, 2008 9:25 pm
Check For Numeric Value in C#
I use this function found on the stackoverflow site to check whether a string is a number:
return System.Text.RegularExpressions.Regex.IsMatch
(TextValue, @"^-?\d+([\.]{1}\d*)?$");
It recognizes integers and decimals. However, it fails on comma separators.
More tips at http://c-sharpe.blogspot.com/
The URI to TrackBack this entry is: http://jdev.blogsome.com/2008/11/07/check-for-numeric-value-in-c/trackback/
No comments yet.
RSS feed for comments on this post.
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>