首页 > 其他 > 详细

单例模式

时间:2016-05-14 10:17:32      阅读:229      评论:0      收藏:0      [点我收藏+]

构造类

 1  class God
 2     {
 3         private static God Instance = new God();
 4         private God() { }
 5         
 6         public void ZhaoYaoDaDi()
 7         {
 8             Console.WriteLine("照耀大地");
 9         }
10         public static God GetInstace()
11         {
12             return Instance;
13         }
14     }

调用

 1 class Program
 2     {
 3         static void Main(string[] args)
 4         {
 5             // God d1 = new God();
 6 
 7             God.GetInstace().ZhaoYaoDaDi();
 8             //God.Instance.ZhaoYaoDaDi();
 9             Console.ReadKey();
10 
11         }
12     }

 

单例模式

原文:http://www.cnblogs.com/yingchuanxiaoge/p/5491901.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!