我是这么接收ID的
int id = Convert.ToInt32(Request.QueryString["id"]);请问如何判断?谢谢大家

解决方案 »

  1.   

    if(Request.QueryString["id"]!="")
    {
        try
        {
          Convert.ToInt32(Request.QueryString["id"]);
        }
        catch()
        {
           "不是数字"
        }
    }
      

  2.   

    if (!Regex.IsMatch(Request.QueryString["id"], @"^[+-]?\d*$"))
    {
    "不是数字"
    }
      

  3.   

    CS0103: 当前上下文中不存在名称“Regex”
      

  4.   


    if (!System.Text.RegularExpressions.Regex.IsMatch(Request.QueryString["id"], @"^[+-]?\d*$"))
    {
    "不是数字"
    }//缺少命名空间System.Text.RegularExpressions
      

  5.   

    News_Detail.aspx?id=我是这么接收ID的
    int id = Convert.ToInt32(Request.QueryString["id"]);ohyear,Small__Wolf的方法只是判断是数字,请如何判断id后面的值不为空,且是整数给大家添麻烦了,谢谢大家!
      

  6.   

    if(Request.QueryString["id"]!="" && Request.QueryString["id"]!=null)
    {
     if (!System.Text.RegularExpressions.Regex.IsMatch(Request.QueryString["id"], @"^(-|\+)?\d+$/"))
         {
             "不是整数"
         }
    }
    else
    {
      "为空!"
    }
      

  7.   

    //返回布尔值 判断输入值是不是数字
    public static bool IsNumeric(string str)  
    {   
    System.Text.RegularExpressions.Regex reg  
    = new System.Text.RegularExpressions.Regex(@"^[+]?\d*$");   
    return reg.IsMatch(str);  
    }