ExtensionMethod.NET Home of 876 C#, Visual Basic, F# and Javascript extension methods


Checks if a string value is numeric according to you system culture.


public static bool IsNumeric(this string theValue)
    long retNum;
    return long.TryParse(theValue, System.Globalization.NumberStyles.Integer, System.Globalization.NumberFormatInfo.InvariantInfo, out retNum);


string value = "abc";
bool isnumeric = value.IsNumeric();// Will return false;
value = "11";
isnumeric = value.IsNumeric();// Will return true;

Author: Faisal Iqbal

Submitted on: 1 apr. 2009

Language: C#

Type: System.String

Views: 15604