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 { get; }
}
public interface IJobTimeEvent : ITimeEvent
{
int JobID { get; }
}
Create a class
public class JobTimeEvent : IJobTimeEvent
{
public int JobID
{
get; internal set;
}
public IJobTimeEventHandler Handler
{
get; internal set;
}
}
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