日期:2014-05-17  浏览次数:20456 次

System.FormatException: 输入字符串的格式不正确。
本帖最后由 wenxiaobo1988 于 2013-08-03 11:59:02 编辑
string name =HttpContext.Current.User.Identity.Name;
return HttpContext.Current.User.Identity.IsAuthenticated? Convert.ToInt32(name) : 0;
Convert.ToInt32(name)System.FormatException: 输入字符串的格式不正确。
我真看不出来这两句话哪里错了,请各路大牛指导指导俺吧

------解决方案--------------------
Convert.ToInt32(name)
name是用户名  例如:wenxiaobo1988  你怎么可以转成Int类型的?
------解决方案--------------------
name无法转换成正常数字
string name = HttpContext.Current.User.Identity.Name;
            int temp = 0;
            return HttpContext.Current.User.Identity.IsAuthenticated ? int.TryParse(name, out temp) ? temp : 0 : 0;