Have stepped on my own toes with what I thought was a very simple piece of code. Code speaks better than words, so here it is.
public interface IResponse
{
IResult Result { get; set; }
}
public class Response<T> : IResponse
where T : IResult
{
public T Result { get; set; }
// COMPILER ERROR: Property 'Result' cannot be implemented property from interface 'IResponse'. Type should be 'IResult'.
}
The compiler does not allow me to do this because IResponse requires Result to be IResult, however I want to take advantage of generics in the implementing class and strongly type the result to T. Is this just not possible, or have I missed something trivial?