In C#,
Is there a way to turn an automatic property into a lazy loaded automatic property with a specified default value?
Essentially, I am trying to turn th
There is a new feature in C#6 called Expression Bodied Auto-Properties, which allows you to write it a bit cleaner:
public class SomeClass
{
private Lazy _someVariable = new Lazy(SomeClass.IOnlyWantToCallYouOnce);
public string SomeVariable
{
get { return _someVariable.Value; }
}
}
Can now be written as:
public class SomeClass
{
private Lazy _someVariable = new Lazy(SomeClass.IOnlyWantToCallYouOnce);
public string SomeVariable => _someVariable.Value;
}