編譯器錯誤 CS0080
更新:2007 年 11 月
錯誤訊息
非泛型宣告中不允許條件約束
找到的語法僅可以用於泛型宣告,套用至型別參數的條件約束。如需詳細資訊,請參閱泛型 (C# 程式設計手冊)。
下列範例會產生 CS0080,因為 MyClass 不是泛型類別,Foo 也不是泛型方法。
namespace MyNamespace
{
public class MyClass where MyClass : System.IDisposable // CS0080 //the following line shows an example of correct syntax
//public class MyClass<T> where T : System.IDisposable
{
public void Foo() where Foo : new() // CS0080
//the following line shows an example of correct syntax
//public void Foo<U>() where U : struct
{
}
}
public class Program
{
public static void Main()
{
}
}
}