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
using System.Text.RegularExpressions;
Regex rxNums = new Regex (@"^\d+$"); // Any positive decimal
if (rxNums.IsMatch("4815162342"))
{
MessageBox.Show("Numeric.");
}
else
{
MessageBox.Show("Not numeric.");
}
|
Digg It!
Del.icio.us
Reddit
StumbleIt
Newsvine
Furl
BlinkList
|
|
Rate this code snippet
Current Comments
|
Related Source Code
There is no related code.
Related Tutorials
There are no related tutorials.
C# Job Search
|