Determines whether [is whole number] [the specified s item] with Regex. - CSharp System.Text.RegularExpressions

CSharp examples for System.Text.RegularExpressions:Match Number

Description

Determines whether [is whole number] [the specified s item] with Regex.

Demo Code


using System.Text.RegularExpressions;
using System.Security.Cryptography;
using System.Globalization;
using System;/*from w w  w.  ja v  a  2  s .  com*/

public class Main{
        /// <summary>
        /// Determines whether [is whole number] [the specified s item].
        /// </summary>
        /// <param name="sItem">The s item.</param>
        /// <returns>
        ///    <c>true</c> if [is whole number] [the specified s item]; otherwise, <c>false</c>.
        /// </returns>
        public static bool IsWholeNumber(this string sItem)
        {
            Regex notWholePattern = new Regex("[^0-9]");
            return !notWholePattern.IsMatch(sItem);
        }
}

Related Tutorials