Created
September 23, 2020 06:14
-
-
Save aershov24/89c6cc45ce0b8f85ff675cf8ad696dcc to your computer and use it in GitHub Desktop.
Markdium-60 .NET Interview Questions Devs Must Focus On (ANSWERED)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public sealed class Singleton | |
| { | |
| // Because Singleton's constructor is private, we must explicitly | |
| // give the Lazy a delegate for creating the Singleton. | |
| static readonly Lazy instanceHolder = | |
| new Lazy(() => new Singleton()); | |
| Singleton() | |
| { | |
| // Explicit private constructor to prevent default public constructor. | |
| ... | |
| } | |
| public static Singleton Instance => instanceHolder.Value; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment