.NET
C#: Lazy is not constrained to static contexts, instance field initializers are: via Stack Overflow
Lazy<T> is not constrained to static contexts.
Instance field initialisers cannot use instance references (but can use static references) as they run outside of the constructor.Though there are arguments for instance field initializers too., I think this is a good reason to initialize fields inside the constructor: there you do have access to instance references (but should not call virtual instance methods or properties) which leads to another reason: consistency as field initializers run in the opposite hierarchy order as constructors (incidentally causing this virtual method restriction).
Boy, that was a long sentence
| Reference: | C#: Lazy is not constrained to static contexts, instance field initialisers are: via Stack Overflow from our NCG partner Jeroen Pluimers at the The Wiert Corner blog. |
Do you want to know how to develop your skillset to become a sysadmin Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. Introduction to NGINX
2. Apache HTTP Server Cookbook
3. VirtualBox Essentials
4. Nagios Monitoring Cookbook
5. Linux BASH Programming Cookbook
6. Postgresql Database Tutorial
and many more ....
I agree to the Terms and Privacy Policy




