编译器错误 CS0416
更新:2007 年 11 月
错误消息
“type parameter”:属性参数不能使用类型参数
类型参数被用作属性参数,这是不允许的。请使用非泛型类型。
下面的示例生成 CS0416:
// CS0416.cs
public class MyAttribute : System.Attribute
{
public MyAttribute(System.Type t)
{
}
}
class G<T>
{
[MyAttribute(typeof(G<T>))] // CS0416
public void F()
{
}
}