C#の静的変数の与アプリケーション

C#の静的変数の与アプリケーション


過言ではないくらいの上に、ネットワーク上のC#の静的に書かれている
が、静的がアプリケーションと同じ効果ではないでしょうか?
だから、テストの結果から、試験した見つけることができる
としても、クライアント側のブラウザと異なる場合、静的変数は、まだアップし蓄積します。


static_variable.cs

public class static_variable
{
   public static int count;	// static
   public int number;		   // nostatic
   
   public static_variable()
   {			
      number = 0;
      number++;
      count++;
   }
   
   public void showData()
   {
      System.Web.HttpContext.Current.Response.Write("-----------------
"); System.Web.HttpContext.Current.Response.Write(string.Format("count 》{0}
",count)); System.Web.HttpContext.Current.Response.Write(string.Format("number 》{0}
",number)); int count_d = 0; count_d--; System.Web.HttpContext.Current.Response.Write(string.Format("count_d 》{0}
",count_d)); } }

webform.aspx

private void Page_Load(object sender, System.EventArgs e)
{
   // 在这里放置使用者程序以初始化网页

   // static_variable.count = 0;
      
   static_variable a = new static_variable();
   a.showData();
      
   static_variable b = new static_variable();			
   b.showData();
      
   static_variable c = new static_variable();
   c.showData();			

}


2015-11-13_190601


2015-11-13_190609


2015-11-13_190618

オリジナル:大列  C#の静的変数と応用


おすすめ

転載: www.cnblogs.com/petewell/p/11516345.html