Skip to content

Instantly share code, notes, and snippets.

@hagbarddenstore
Last active December 18, 2015 20:48
Show Gist options
  • Save hagbarddenstore/5842398 to your computer and use it in GitHub Desktop.
Save hagbarddenstore/5842398 to your computer and use it in GitHub Desktop.
public class StaticResources
{
public static IState State
{
get { return StateClass.Instance; }
}
public interface IState
{
}
private class StateClass : IState
{
private static volatile StateClass instance;
private static object SyncRoot = new object();
private StateClass()
{
}
public static StateClass Instance
{
get
{
if (instance == null)
{
lock (SyncRoot)
{
if (instance == null)
{
instance = new StateClass();
}
}
}
return instance;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment