c#数据转换的一点疑问?
如下的代码不是很清楚,我把自己的疑问写在注释里了:
if (intUserNum == 0)
Application < "user "> = strUserName.ToString();
else
Application < "user "> = Application < "user "> + ", " + strUserName.ToString();
intUserNum += 1; //intUserNum是整数型变量
object obj = Convert.ToInt32(intUserNum); //既然已是整数型为何多此一举再转换?
Application < "userNum "> = obj; //在Global.asax中Application < "userNum "> 被初始化为数值0,为何在此又被赋值成一个对象类型?
------解决方案--------------------intUserNum += 1; //intUserNum是整数型变量
Application < "userNum "> = intUserNum; //直接这样就可以了