Posted By

dmilligan on 05/06/14


Tagged

Singleton lazy


Versions (?)

Singleton


 / Published in: C#
 

Singleton pattern for C# 4.0 or above.

  1. public sealed class Singleton
  2. {
  3. private static readonly Lazy<Singleton> lazy =
  4. new Lazy<Singleton>(() => new Singleton());
  5.  
  6. public static Singleton Instance { get { return lazy.Value; } }
  7.  
  8. private Singleton()
  9. {
  10. }
  11. }

Report this snippet  

You need to login to post a comment.