鸿 网 互 联 www.68idc.cn

当前位置 : 服务器租用 > 手机系统开发 > J2ME > >

静态变量和非静态变量

来源:互联网 作者:佚名 时间:2015-09-25 05:47
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) {
 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

网友评论
<