Determines whether the specified s item is number. - CSharp System

CSharp examples for System:Math Number

Description

Determines whether the specified s item is number.

Demo Code


using System.Text.RegularExpressions;
using System.Security.Cryptography;
using System.Globalization;
using System;/*  w  ww. ja  va 2s  . c  o m*/

public class Main{
        /// <summary>
        /// Determines whether the specified s item is number.
        /// </summary>
        /// <param name="sItem">The s item.</param>
        /// <returns>
        ///    <c>true</c> if the specified s item is number; otherwise, <c>false</c>.
        /// </returns>
        public static bool IsNumber(this string sItem)
        {
            double result;
            return (double.TryParse(sItem, NumberStyles.Float, NumberFormatInfo.CurrentInfo, out result));
        }
}

Related Tutorials