Singleton Alternative - is it equivalent?
问题 Quick question - I know that the standard singleton pattern is as follows: Original public class Singleton1 { public static Singleton1 _Instance; public static Singleton1 Instance { get { if (_Instance == null) { _Instance = new Singleton1(); } return _Instance; } } private Singleton1() { } } But it seems like this code is unnecessary. To me, you could accomplish the same thing with either of the following simple design patterns: Version 2 public class Singleton2 { public static readonly