首页 > 学院 > 开发设计 > 正文

在继承中子类自动实现单例模式

2019-11-17 02:45:48
字体:
来源:转载
供稿:网友

在继承中子类自动实现单例模式

@Paradox 技术支持

12345678910111213public abstract class Base<T> where T : new(){PRivate static T _instance;public static T Instance{get{if (_instance == null)_instance = new T();return _instance;}}}
123public sealed class A : Base<A>{}

更多内容:http://www.liubaicai.net/index.php/archives/366


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表