I have a Response class with two constructors. One receive a Result object and other a generic Result object.
How to declare the generic constructor of Response class to get the generic object?
In this sample code, the non-generic constructor is used.
var result = new Result<SomeModel>();
var response = new Response(result); // should use the generic constructor but uses the normal
public interface IModel
{
}
public class SomeModel : IModel
{
public string Text { get; set; }
}
public class Result<T> : Result where T : class, IModel
{
public T Model { get; set; }
}
public class Result
{
public bool Success { get; set; }
}
public class Response
{
public Response(Result<IModel> data)
{
}
public Response(Result data)
{
}
}