Accessing a non-static member via Lazy or any lambda expression

You can move it into constructor:

private Lazy<int> lazyGetSum;
public MyClass()
{
   lazyGetSum = new Lazy<int>(new Func<int>(() => X + Y));
}

See @JohnSkeet answer below for more details about the reason of the problem.
Accessing a non-static member via Lazy<T> or any lambda expression

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)