Inheritance: when implementing an interface which define a base class property why cant the class im
- by Deepak
Lets create some interfaces
public interface ITimeEventHandler
{
string Open();
}
public interface IJobTimeEventHandler: ITimeEventHandler
{
string DeleteJob();
}
public interface IActivityTimeEventHandler: ITimeEventHandler
{
string DeleteActivity();
}
public interface ITimeEvent
{
ITimeEventHandler Handler;
}
Another Interface
public interface IJobTimeEvent :ITimeEvent
{
int JobID;
}
Create a class
public class JobTimeEvent : IJobTimeEvent
{
public int JobID = 0;
public IJobTimeEventHandler Handler = null;
}
My question is .. when implementing an interface which define a base class property why cant the class implementing interface return a derived class type object ??
For ex in class JobTimeEvent, IJobtimeEvent needs a property of type ITimeEventHandler but why IJobTimeEventHandler type is not allowed which derived from ITimeEventHandler