dotnet-Snippets.com
Snippets: 57 | Registered User: 27 | Visitors online: 4
Main Menu

Home
Random Snippet
FAQs
Contact Us
Imprint
RSS Feeds

Rss All languages
Rss C#
Rss VB.NET
Rss C++
Rss J#
Rss ASP.NET
Google Ads

Sri Lanka .NET 
                Forum Member
IsPositiveInteger as Extension Method

Author: Jan Welker
Programming Language: C# Rating:
not yet rated

Views: 279

Description:

Determines whether the given string is a positive integer.



C#
1
2
3
4
5
6
7
8
9
10
using System.Text.RegularExpressions;

public static class Extensions
{
    public static bool IsPositiveInteger(this string s)
    {
        Regex regex = new Regex(@"^\d*$");
        return regex.IsMatch(s);
    }
}

This Snippets could be interesting for you:

Poor Excellent
1 2 3 4 5 6 7 8 9 10
Sign in to vote for this snippet.

Comments:
(Please log in to wrtite an comment.)