protected void Page_Load(object sender, EventArgs e)
    {
            int a=0;
    }    public int count(int s)
   {
       // 在这里如何引用a这个变量?    }

解决方案 »

  1.   

    protected void Page_Load(object sender, EventArgs e)
        {
                int a=0;
                ViewState["a"]=a;
        }    public int count(int s)
       {
           // 在这里如何引用a这个变量?
             //int b=int.Parse(ViewState["a"]+"");这就可以了
        }
      

  2.   


    int a;
    protected void Page_Load(object sender, EventArgs e)
        {
                a=0;
        }    public int count(int s)
       {
           // 在这里如何引用a这个变量?    }
      

  3.   

    //这就是方法,类型自己转换
    protected void Page_Load(object sender, EventArgs e)
        {
                int a=0;
                ViewState["a"]=a;
        }    public int count(int s)
       {
           // 在这里如何引用a这个变量?
             //int b=int.Parse(ViewState["a"]+"");这就可以了
        }