Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Created September 28, 2017 09:45
Show Gist options
  • Save NMZivkovic/1020b622ddaa44c68c2bb27d566cd8b5 to your computer and use it in GitHub Desktop.
Save NMZivkovic/1020b622ddaa44c68c2bb27d566cd8b5 to your computer and use it in GitHub Desktop.
namespace SingletonExamples
{
/// <summary>
/// Broken, non thread-save solution.
/// Don't use this code.
/// </summary>
public class SingletonFirst
{
private static SingletonFirst _instance;
private SingletonFirst() { }
public static SingletonFirst Instance
{
get
{
if (_instance == null)
{
_instance = new SingletonFirst();
}
return _instance;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment