Originally published on 2018-12-01
Comparing lazy instance creation in C# vs Java 8, (continuing my previous post)
In C# there is Lazy class, so for example to make a lazy property in C# becomes even more elegant:
(note: in this example static base factory of Clazz requires an instance of calling class)
private Lazy<Clazzz> _clazzField;
public Clazzz ClazzzProperty => _clazzField.Value;
SomeConstructor()
{
_clazzField = new Lazy<Clazzz>(GetPrimaryController(this));
}