public class Singleton { public static Singleton Instance=new Singleton(); public int Id { get; set; }private Singleton() { } public int Name { get; set; } }
单例 模式的关键点在于: 构造韩式 private 不能外部 new, 只能内部new
TRANSLATE with x English TRANSLATE with COPY THE URL BELOW Back EMBED THE SNIPPET BELOW IN YOUR SITE Enable collaborative features and customize widget: Bing Webmaster Portal Back