静态变量和非静态变量

 public partial class WebForm1 : System.Web.UI.Page
    {
        public int i;
        public static int j;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                i = 9;
                j = 9;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Write(i.ToString()+"   "+j.ToString());
        }

    }

  

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
    </div>
    </form>
</body>
</html>

点击按钮后运行结果 

0  9

posted on 2013-06-04 23:15  奋斗的笨小孩  阅读(173)  评论(0)    收藏  举报