@{var typeId = Request.QueryString["cid"];
          int? cid;
         cid = (string.IsNullOrEmpty(typeId) ?  null : ( Convert.ToInt32( typeId)) );
}
( Convert.ToInt32( typeId)) )   这一块下边出现红线,显示有错,该怎么写因为有个函数里边有个 类型就是 int ?,所以我进行上边转换

解决方案 »

  1.   

    try cid = string.IsNullOrEmpty(typeId) ?  null : (int?) Convert.ToInt32( typeId);
      

  2.   


    谢谢,我去试试我现在写成
            @{var typeId = Request.QueryString["cid"];
              int? cid;
              if (string.IsNullOrEmpty(typeId))
              {cid = null;}
              else
              {cid = Convert.ToInt32(typeId);}
             
            }