• 2 Posts
  • 25 Comments
Joined 3 years ago
cake
Cake day: July 2nd, 2023

help-circle



  • KoalaUnknown@lemmy.worldOPtoProgrammer Humor@programming.devWhat's a readability
    link
    fedilink
    arrow-up
    10
    arrow-down
    1
    ·
    edit-2
    4 months ago

    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;
    }