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()  
        {  
        }  
    }  
}