日期:2014-05-20  浏览次数:20439 次

变量声明冲突问题?
int   SumPages=0;
int   SRPages=0;
int   pC=1;
string   uppage= " ";
string   downpage= " ";
private   void   Page_Load(object   sender,   System.EventArgs   e)
{
if(Request.QueryString[ "pC "]==null)
{
pC=1;
}
else
{
pC=Convert.ToInt32(Request.QueryString[ "pC "]);
}

if   (pC <=1)
{
string   uppage= "http://localhost/AD/AE.aspx?pC=1 ";
}
else
                        {
string   uppage= "http://localhost/AD/AE.aspx?pC= "+Convert.ToString(pC-1);
}
        if   (pC> =SumPages)
{
string   downpage= "http://localhost/AD/AE.aspx?pC= "+SumPages.ToString();
}
else
          {
string   downpage= "http://localhost/AD/AE.aspx?pC= "+Convert.ToString(pC+1);
}
string   firstpage= "http://localhost/AD/AE.aspx?pC=1 ";
string   lastpage= "http://localhost/AD/AE.aspx?pC= "+SumPages.ToString();
Response.Write( " <table   width=100%   border=1> ");
Response.Write( " <tr> <td> 总记录数为 "+SR.ToString()+ "条     每页10条     当前页数: "+pC.ToString()+ "/共有 "+SumPages.ToString()+ "页 </td> ");
Response.Write( " <td> <a   href= "+firstpage+ "> 第一页 </a>         <a   href= "+uppage+ "> 上一页 </a> &nbsp; <a   href= "+downpage+ "> 下一页 </a> &nbsp; <a   href= "+lastpage+ "> 最后一页 </a>       转到:页   </td> ");
Response.Write( " </tr> </table> ");
                                }

出现以下错误
"downpage "   与声明   "上级类名.downpage "冲突
"uppage "   与声明   "上级类名.uppage "冲突

------解决方案--------------------
if (pC <=1)
{
uppage= "http://localhost/AD/AE.aspx?pC=1 ";
}
else
{
uppage= "http://localhost/AD/AE.aspx?pC= "+Convert.ToString(pC-1);
}
if (pC> =SumPages)
{
downpage= "http://localhost/AD/AE.aspx?pC= "+SumPages.ToString();
}
else
{
downpage= "http://localhost/AD/AE.aspx?pC= "+Convert.ToString(pC+1);
}

改为

if (pC <=1)
{
uppage= "http://localhost/AD/AE.aspx?pC=1 ";
}
else
{
uppage= "http://localhost/AD/AE.aspx?pC= "+Convert.ToString(pC-1);
}
if (pC> =SumPages)
{
downpage= "http://localhost/AD/AE.aspx?pC= "+SumPages.ToString();
}
else
{
downpage= "http://localhost/AD/AE.aspx?pC= "+Convert.ToString(pC+1);
}
------解决方案--------------------
去掉
string uppage= " ";
string downpage= " ";



------解决方案--------------------
if (pC <=1)
{
uppage= "http://localhost/AD/AE.aspx?pC=1 ";