This syntax is only required for a first call of a lazy instantiation. The instance should still be returned at the end:
private static object SyncRoot = new object();
private static object TheLazyOne = null;
public static object Instance{
get{
if (TheLazyOne == null)
{
lock (SyncRoot)
{
if (TheLazyOne == null)
TheLazyOne = new object();
}
}
return TheLazyOne;
}
}
I hope that explanation is what you were looking for. Please let me know if I mis-understood.
(PS: I think .Net5 has an equivalent (Citation needed^!):
private static Lazy<object> TheLazyOne = new Lazy<object>();
public static object Instance{
get{
return TheLazyOne.Value;
}
} </object></object>