我有相同的代码:
public class BaseModel{}
public class Model1 : BaseModel{}
public interface ITest<T> {}
public class Test : ITest<Model1>{}
then..
some other class method
{
ITest<Model1> test = new Test();
//then...
ITest<BaseModel> casted = test as ITest<BaseModel>; // return null...
}
有什么想法吗?为什么我不转换为基本模型?
谢谢..