This is what I want my classes to look like, but this code won't compile. How do I make it work?
public interface ISomeInterface
{
string AMember { get; }
}
public abstract class BaseClass
{
public abstract ISomeInterface AObject { get; }
public abstract IEnumerable<ISomeInterface> AMethod();
}
public class DerivedClass<T> : BaseClass where T : ISomeInterface
{
public T AObject { get; private set; }
public IEnumerable<T> AMethod()
{
return null;
}
}
Compiler errors
'Delfin.Accountancy.DerivedClass' does not implement inherited abstract member 'Delfin.Accountancy.BaseClass.AObject.get'
'Delfin.Accountancy.DerivedClass' does not implement inherited abstract member 'Delfin.Accountancy.BaseClass.AMethod()'
Running on c# 5.0.
Notes
I've tried most obvious implementations, but any of them allow me to implement the base class and expose the strongly typed members at once.
I don't want to make the base class generic, because I'll create static methods on the base class, and also create extension methods that might work in every case of derived classes.
I also need the derived class to be generic, because T has more members than ISomeInterface in the real world case.
Thanks!