public class P { }
public class B : P { }
public class A : P { }
public interface Interface<T> where T : P { }
public class IA : Interface<A> { }
public class IB : Interface<B> { }
public class Test
{
public void WhatTheFuck()
{
Interface<P> p;
p = new IA();// cast error here
p = new IB();// cast error here
//... somthing about interface<p>
}
}
Run Code Online (Sandbox Code Playgroud)
得到这个错误:
严重性代码描述项目文件行抑制状态错误 CS0266 无法将类型“AssUploaderSystem.IA”隐式转换为“AssUploaderSystem.Interface”
我想制定一个通用的解决方案,因为 A 类和 B …