Compiler Error CS0406
The class type constraint 'constraint' must come before any other constraints
When a generic type or method has a class type constraint, that constraint must be listed first. To avoid this error, move the class type constraint to the beginning of the constraint list.
The following sample generates CS0406.
// CS0406.cs
// compile with: /target:library
interface I {}
class C {}
class D<T> where T : I, C {} // CS0406
class D2<T> where T : C, I {} // OK
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: