編譯器錯誤 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()
{
}
}