Object initializers outside a constructor (or method) has to refer to static members only. This is because the instance hasn’t been constructed until the constructor is run, hence the fields are not “ready yet” and therefor cannot be referenced. Static fields work because they are initialized before fields.
Note that the error isn’t caused by Lazy<T>
, it is caused by the lambda expression. The workaround (and proper way of doing this) is to initialize Result
in a constructor.