Twitter <%=Resources.labels.subscribe %>

C# IsNumeric Function

  • I’m adding this to my code snippets since I use it a lot. It’s a function to check if an object is numeric in C#. It’s similar to the VB IsNumeric method.
     
    public static bool IsNumeric(object expression)
    {
    if (expression == null)
    return false;

    double number;
    return Double.TryParse(Convert.ToString(expression, CultureInfo.InvariantCulture),
    System.Globalization.NumberStyles.Any, NumberFormatInfo.InvariantInfo, out number);
    }

     

    Tags:

    Permalink |

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading


Intro

My name is Brent Lamborn. I´m 35 years old and I live in Nebraska. I've been coding with the .NET Framework since 2003. I'm a former Marine and I have 5 boys.


View Brent Lamborn's LinkedIn profileView Brent Lamborn's profile

Sponsored By

Categories

Tag Cloud

Blog Roll