Esempio n. 1
0
 static void Main(string[] args)
 {
     //单例模式:保证该类只有一个实例化的对象
     LLo.GetToolSingle().GetSum();
     LLo.GetToolSingle().GetSum();//再次声明时,还是只有一个theTool;
     Console.ReadKey();
 }
Esempio n. 2
0
 //3.定义一个公有的静态方法,返回值为该类类型的,以供外部调用
 public static LLo GetToolSingle()
 {
     if (theTool == null)
     {
         theTool = new LLo();
     }
     return(theTool);
 }