see.aspx?id=369在 see.aspx.cs 代码中我想这样做:string getid = Request.query["id"];if(getid 是正整数)   // 如何判断 getid 是正整数呢
{
   do something .....
}
else
{
   do otherthing .....}

解决方案 »

  1.   

    public static int CvtInt(string Value)
            {
                int n = 0;
                try
                {
                    n = int.Parse(Value);
                }
                catch
                {
                }
                return n;
            }
    调用它做判断就可以了
      

  2.   

    楼上正解
    public static int CvtInt(string Value)
            {
                int n = 0;
                try
                {
                    return n = int.Parse(Value);
                }
                catch
                {
                    return 0;
                }
            }我觉得这样比较好些
      

  3.   

    public static int CvtInt(string Value)
            {
                try
                {
                    return int.Parse(Value);
                }
                catch
                {
                    return 0;
                }
            }
      

  4.   

    就用 try catch ???除了这种方法有没有专门判断字符为正整数的函数呢 ?
      

  5.   

    Public Function IsNumeric(ByVal Expression As Object) As Boolean
    //这个是VB中的函数,可以用来直接判断,你添加引用即可使用
      

  6.   

    我用的是 C#  啊,不能用---------Public Function IsNumeric(ByVal Expression As Object) As Boolean
    //这个是VB中的函数,可以用来直接判断,你添加引用即可使用
    ----------