最简单的单例

 /// <summary>

        /// 获取当前实例

        /// </summary>

        public static ClassTest Instance

        {

            get

            {

                if (_instance == null)

                {

                    lock (typeof(ClassTest ))

                    {

                        //创建实例

                        if (_instance == null){  _instance = new ClassTest ();}

                    }

                }

                return _instance;

            }

        }

posted @ 2011-10-14 09:55  老皆知  阅读(159)  评论(0编辑  收藏  举报