.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Check whether the string is numeric in c#

Posted By:Rajshree       Posted Date: September 20, 2010    Points: 10    Category: Visual Studio    URL: http://www.dotnetspark.com  

Check whether the string is numeric in c#

  public static bool IsNumeric(this String stringToCheck, out int numericValue, int defaultValue)
            Match isNumberMatchResult = Regex.Match(stringToCheck, "[0-9]+");
            string resultingNumber = MergedMatch(isNumberMatchResult);

            if (resultingNumber.Length > 0)
                numericValue = int.Parse(resultingNumber);
                return true;

            numericValue = defaultValue;
            return false;


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend