Created
March 13, 2020 04:20
-
-
Save Miragecore/5798a064fa849b184d0e972d092e5a73 to your computer and use it in GitHub Desktop.
singleton pattern
This file contains 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
//from https://csharpindepth.com/articles/singleton | |
public sealed class Singleton | |
{ | |
private static readonly Singleton instance = new Singleton(); | |
// Explicit static constructor to tell C# compiler | |
// not to mark type as beforefieldinit | |
static Singleton() | |
{ | |
} | |
private Singleton() | |
{ | |
} | |
public static Singleton Instance | |
{ | |
get | |
{ | |
return instance; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment