Can anyone help me to understand the benefit of using System.Lazy with Singleton Design Pattern.
Can anyone help me to understand the benefit of using System.Lazy with Singleton Design
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The best source on C# Singletons (also covers
Lazy<>) belongs to Jon Skeet: http://csharpindepth.com/Articles/General/Singleton.aspxSuppose you want to have a class that :
If most of the above conditions are true, you will need to ensure that the class is Singleton, and the unique instance is lazily initialized (not initialized until needed) If you target C# 4.0 or later, using
Lazy<>makes your design simpler, more readable and easier to remember.