读书人

global.asax设置有关问题

发布时间: 2012-02-01 16:58:19 作者: rapoo

global.asax设置问题
void Session_Start(object sender, EventArgs e)
{
// 在新会话启动时运行的代码
string StrTxt;//当前的计数值
string PathStr;//计数的路径
Integer IntCount;//运行中增减的数值
Application.Lock();
PathStr=Server.MapPath( "count.txt ");
StrTxt = Trim(ReadText(PathStr));
if (Trim(StrTxt))= " "or Not IsNumeric(Trim(StrTxt))
{ IntCount=1;
}
else
{ IntCount=Convert.ToInt32(Trim(StrTxt))+1;
}
end if
WriteText(PathStr,Convert.ToString(IntCount);
Application( "currcount ")=IntCount;
Application( "active ")=Application( "active ")+1;

Application.UnLock();

}


编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。

编译器错误信息: CS1525: 无效的表达式项“=”

源错误:



行 38: PathStr=Server.MapPath( "count.txt ");
行 39: StrTxt = Trim(ReadText(PathStr));
行 40: if (Trim(StrTxt))= " "or Not IsNumeric(Trim(StrTxt))
行 41: { IntCount=1;
行 42: }




[解决办法]
if ((Trim(StrTxt) == " ") || (!IsNumeric(Trim(StrTxt))))
{
}
[解决办法]
语法上有问题,VB.net和C#混淆了!不知版主是用C#还是VB.net?
StrTxt = Trim(ReadText(PathStr));
if (Trim(StrTxt))= " "or Not IsNumeric(Trim(StrTxt)) //错误,且Trim(StrTxt)与上一步重复,其他错误解
//决同2楼
{ IntCount=1;
}
else
{ IntCount=Convert.ToInt32(Trim(StrTxt))+1;
}
end if

读书人网 >C#

热点推荐