IsNumeric() function in C#?

by Vahid 3. January 2009 05:36

hi,

as you may know c# is missing the nice and usfull IsNumeric function which is available in VB.net. but it is a trivial task to implement a generic equvelant function for it. look at the following code. it will return true if the value is numeric and false if the value is false.

static bool IsNumeric(object value)

{

double retNum;return Double.TryParse(Convert.ToString(value), System.Globalization.NumberStyles.Any, System.Globalization.NumberFormatInfo.InvariantInfo, out retNum);

}

 

Tags: ,

Technical | .Net