myStr = "1"; try { int i = Int32.Parse(myStr); } catch { Response.write("not a number"); }
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; }
try
{
int i = Int32.Parse(myStr);
}
catch
{
Response.write("not a number");
}
{
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;
}