Geekpedia Programming Tutorials






Validate String For Positive Integer Values

A very simple way to validate a string for positive integer values using C# and regular expressions.

On Saturday, October 18th 2008 at 05:00 AM
By Andrew Pociu (View Profile)
****-   (Rated 4 with 4 votes)
Contextual Ads
More C# Resources
Advertisement
  1. using System.Text.RegularExpressions;
  2.  
  3. Regex rxNums = new Regex(@"^\d+$"); // Any positive decimal
  4. if (rxNums.IsMatch("4815162342"))
  5. {
  6.     MessageBox.Show("Numeric.");
  7. }
  8. else
  9. {
  10.     MessageBox.Show("Not numeric.");
  11. }
Digg Digg It!     Del.icio.us Del.icio.us     Reddit Reddit     StumbleUpon StumbleIt     Newsvine Newsvine     Furl Furl     BlinkList BlinkList

Rate Rate this code snippet
Comment Current Comments
by Mohan on Monday, December 29th 2008 at 07:36 AM

It's was nice tutorial.


Comment Comment on this tutorial
Name: Email:
Message:
Comment Related Source Code
There is no related code.

Comment Related Tutorials
There are no related tutorials.

Jobs C# Job Search
My skills include:

Enter a City:

Select a State:


Advanced Search >>
Latest Tech Bargains

Advertisement

Free Magazine Subscriptions

Today's Pictures

Today's Video

Other Resources

Latest Download

Latest Icons