• 1 Post
  • 4 Comments
Joined 2 years ago
cake
Cake day: July 2nd, 2023

help-circle



  • Yes, it’s cut down for the meme.

    In reality, it would probably look more like this:

    
    public class Singleton
    {
      private static readonly Lazy<Singleton> lazy = new Lazy<Singleton>(() => new Singleton());
    
      private Singleton(){}
    
      public static Singleton Instance
      {
          get
          {
             return lazy.Value;
          }
       }
    }
    
    

    or this:

    
    public class Singleton
    {
       private static readonly Singleton instance = new Singleton();
    
       private Singleton(){}
    
       public static Singleton Instance => instance;
    }