读书人

cid = (string.IsNullOrEmpty(typeId)

发布时间: 2013-02-15 15:46:56 作者: rapoo

cid = (string.IsNullOrEmpty(typeId) ? null : ( Convert.ToInt32( typeId)) ) 有


@{var typeId = Request.QueryString["cid"];
int? cid;
cid = (string.IsNullOrEmpty(typeId) ? null : ( Convert.ToInt32( typeId)) );
}


( Convert.ToInt32( typeId)) ) 这一块下边出现红线,显示有错,该怎么写

因为有个函数里边有个 类型就是 int ?,所以我进行上边转换
[解决办法]
try

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

读书人网 >asp.net

热点推荐