怎么实现一个有不同参数的方法的Interface
coyun 2016-04-28 09:23:12 我试图写一个Interface ITest,里面有一个方法RunTest,需要接收不同的参数。
public interface ITest<T> where T: TestInput {
void RunTest(T ts);
}
public abstract class ModelInput {
}
public class InputA: TestInput {
}
public class TestClass: ITest<InputA> {
public void RunTest(InputA aa) {
}
}
ITest<TestInput> _instance = new TestClass();
最后当我试图给TestClass构造一个实例的时候,出错了:说不能隐性的将TestClass类型转换为ITest<TestInput>类型。