对,没有全局变量这个概念了 
一般的做法是把全局变量全部封装到一个类中,使用static就可以了。 
各位高手有什么意见

 

public   class   GVar 
{ 
        public   static   string   szName   =   " "; 
        public   static   int   nAge   =   0; 
} 

//   在这个类里面使用GVar类中的变量 
public   class   MyForm   :   System.Windows.Forms 
{ 
    ... 

    public   void   fun() 
    {     //   这里相当于使用全局变量(其他地方用法也一样) 
            GVar.szName   =   "Bill "; 
            GVar.nAge   =   10; 
    } 
}

  

 

相关文章:

  • 2021-11-18
  • 2022-03-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
猜你喜欢
  • 2021-11-21
  • 2021-11-17
  • 2021-11-08
  • 2022-12-23
  • 2022-01-31
  • 2022-12-23
相关资源
相似解决方案