【发布时间】:2013-02-07 10:47:13
【问题描述】:
给出下面的示例代码,谁能解释为什么第一个typeof() 调用成功但第二个失败?不管它们是类还是接口,它都会失败。
interface ITestOne<T1>
{
T1 MyMethod();
}
interface ITestMany<T1, T2>
{
T1 MyMethod(T2 myParameter);
}
void Main()
{
var typeOne = typeof(ITestOne<>); //This line works
var typeTwo = typeof(ITestMany<>); //Compile error
}
【问题讨论】:
标签: c# generics compiler-errors typeof