Is Int by Regex - CSharp System.Text.RegularExpressions

CSharp examples for System.Text.RegularExpressions:Match Number

Description

Is Int by Regex

Demo Code


using System.Text.RegularExpressions;
using System;/*from   ww  w  .java 2 s. c om*/

public class Main{
        public static bool IsInt(string _value)
        {
            Regex regex = new Regex(@"^(-){0,1}\d+_");
            if (regex.Match(_value).Success)
            {
                if ((long.Parse(_value) > 0x7fffffffL) || (long.Parse(_value) < -2147483648L))
                {
                    return false;
                }
                return true;
            }
            return false;
        }
}

Related Tutorials