5 Comments

  • I was going to say that many of the methods listed in the discussion would not take into account numbers written in an exponential format. However the methods listed in Doug Ferguson's link would.

  • I just reference the MS.VB dll, or you can use Double.TryParse().

  • I'm Chad from the Tulsa DNUG (also the recently enigmatic blogger), so I extend my appreciation for any value you derived from the discussion :)

  • a possible Hybrid implementation:



    public bool IsNumeric(object s)

    {

    if ( s is decimal )

    {

    return true;

    }

    if ( s is int )

    {

    return true;

    }

    if ( s is short )

    {

    return true;

    }

    if ( s is long )

    {

    return true;

    }

    if ( s is uint )

    {

    return true;

    }

    if ( s is float )

    {

    return true;

    }

    if ( s is ulong )

    {

    return true;

    }

    if ( s is ushort )

    {

    return true;

    }

    if ( s is char )

    {

    return (((char)s > 57 || (char)s < 48));

    }

    if (s is string)

    {

    System.Double OutputValue;

    return System.Double.TryParse((string) s,

    NumberStyles.Any | NumberStyles.AllowHexSpecifier | NumberStyles.AllowHexSpecifier,

    CultureInfo.CurrentCulture , out OutputValue );

    }



    return false;



    }

  • thanks a mill for highlighting this - wasn't life so much simpler back in those classic asp days!

Comments have been disabled for this content.