Is Numeric by Regex - CSharp System.Text.RegularExpressions

CSharp examples for System.Text.RegularExpressions:Match Number

Description

Is Numeric by Regex

Demo Code


using System.Text.RegularExpressions;
using System.Text;
using System.Linq;
using System.IO;//from   w  w  w.  j  a  v  a 2s.  c o m
using System.Globalization;
using System.Collections.Generic;
using System;

public class Main{
        public static bool IsNumeric(this string value)
        {
            var regex = new Regex(@"^\-?[0-9]+$");
            return regex.IsMatch(value);
		}
}

Related Tutorials