Skip to content

Instantly share code, notes, and snippets.

@AlphaGit
Created April 25, 2016 01:42
Show Gist options
  • Save AlphaGit/ab3506c321179a67db6e044ec34e5f21 to your computer and use it in GitHub Desktop.
Save AlphaGit/ab3506c321179a67db6e044ec34e5f21 to your computer and use it in GitHub Desktop.
Typical Singleton Pattern
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