Session原理
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace WebApplication1
{
public partial class 自增 : System.Web.UI.Page
{
public int i = 0;//每次调用都实例化一个自增对象(自增 p = new 自增();p.i=0;)
private static int j = 0;//static 是一个全局变量与实例化无关。
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)//这里不会自增
{
i++;
Label1.Text = i.ToString();
}
protected void Button2_Click(object sender, EventArgs e)//这里会自增
{
j++;
Label2.Text = j.ToString();
}
}
}