Created
April 25, 2016 01:42
-
-
Save AlphaGit/ab3506c321179a67db6e044ec34e5f21 to your computer and use it in GitHub Desktop.
Typical Singleton Pattern
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 class MySingletonClass { | |
private static MySingletonClass _instance; | |
// private constructor | |
private MySingletonClass() { } | |
// public accessor property that instantiates if needed | |
public static Instance => _instance ?? (_instance = new MySingletonClass()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment