Let's say I have a helper class like
public class Selection<T, W> : ISelection<T,W> where W : ICollection<T>
{
public Selection(Func<W> selectableItemsProvider)
{
...
}
}
As C# does not support delegating interface implementation, I thought I'd save myself a bit of boilerplate and just extend the Selection class...
public class MyFoo : Selection<Blah, List<Blah>>
{
private List<Blah> _blahs = new List<Blah>();
public MyFoo() : base(() => _blahs)
{
...
}
}
Except I cannot do that, can I, because
Cannot access non-static property '_blahs' in static context
even though I already know the provider won't be invoked until after object construction.
Is there a way around this or am I stuck with adding boilerplate code?