Compiler Error CS0080
Constraints are not allowed on non-generic declarations
The syntax found may only be used in a generic declaration to apply constraints to the type parameter. For more information, see Generics.
The following sample generates CS0080 because MyClass is not a generic class and Foo is not a generic method.
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()
{
}
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: