sorry for the explanation but this is the best i can describe it, hopefully the code will help. (i've removed implementation from the classes and renamed to make it as bare bones as i can)
I get a cast exception as i convert my interface to interface below is the code. Is there anyway i can get this to work?
var instance = new Service1() as IService<PocoClass1>; //this works
var instance2 = new Service1() as IService<PocoBase>; // this fails but i want it to work
public abstract class PocoBase
{
public int GetAll()
{
return 0;
}
}
public class PocoClass1: PocoBase
{
}
public interface IService<T> where T : PocoBase
{
void Add(int x);
}
public class Service1 : IService<PocoClass1>
{
public void Add(int x)
{
}
}