Skip to content

Instantly share code, notes, and snippets.

@ssukhpinder
Created May 25, 2021 10:11
Show Gist options
  • Save ssukhpinder/43411bfd84cdbd86386df0e95ca085c3 to your computer and use it in GitHub Desktop.
Save ssukhpinder/43411bfd84cdbd86386df0e95ca085c3 to your computer and use it in GitHub Desktop.
public class SingletonExample
{
private string Name { get; set; } = "Hello from singleton";
private static SingletonExample _instance;
public static SingletonExample Instance
{
get
{
if (_instance == null)
{
_instance = new SingletonExample();
}
return _instance;
}
}
public SingletonExample()
{
}
public string GetName() => Name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment