Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

c# IsNumeric method (See related posts)

From Subtext source code - http://subtextproject.com/

public static bool IsNumeric(string text)
{
    return Regex.IsMatch(text,"^\\d+$");
}

Comments on this post

nico posts on May 25, 2007 at 10:41
What about numbers whith decimal Point?

Use
return Regex.IsMatch(text,"^\\d+(\\.\\d+)?$");
or
return Regex.IsMatch(text,@"^\d+(\.\d+)?$");

You need to create an account or log in to post comments to this site.


Click here to browse all 4863 code snippets

Related Posts