Is a lazy instance about using smaller code, but getting the same result? Of course, this is usually a good thing (ensuring that the code is short / efficient does not impair readability / maintainability).
Please refer to this lazy instance:
public sealed class Singleton
{
private Singleton()
{
}
public static Singleton Instance { get { return Nested.instance; } }
private class Nested
{
static Nested()
{
}
internal static readonly Singleton instance = new Singleton();
}
}
No private property Instance(I know this is implicit) - is this what makes it lazy - is it a fact that we don’t have the customization facility in the property public static Singleton Instance?
Dave source
share