vb.net的这个函数:IsNumeric()在c#里怎么写啊

解决方案 »

  1.   

    myStr = "1";
    try
    {
        int i = Int32.Parse(myStr);
    }
    catch
    {
        Response.write("not a  number");
    }
      

  2.   

    bool IsNumeric(object o)
    {
      if (o is System.SByte
       || o is System.Byte
       || o is System.Char
       || o is System.Int16
       || o is System.UInt16
       || o is System.Int32
       || o is System.UInt32
       || o is System.Int64
       || o is System.UInt64
       || o is System.Single
       || o is System.Double
       || o is System.Decimal
      ) return true;
      try   { System.Double.Parse(o.ToString()); }
      catch { return false; }
      return true;
    }