Constraint '<constraint1>' conflicts with the constraint '<constraint2>' already specified for type parameter '<typeparametername>'

A generic type is declared with conflicting constraints on a type parameter.

The following statement can generate this error.

Public Class testClass(Of t As {Structure, Class })

The constraints Structure and Class cause a conflict for type parameter t, because the Structure constraint requires that the corresponding type argument be a value type, while Class requires that it be a reference type.

Error ID: BC32119

To correct this error

  • Change the type parameter constraints to avoid conflicts.

See Also

Concepts

Generic Types in Visual Basic

Value Types and Reference Types

Reference

Type List

Structure (Visual Basic)

Class (Visual Basic)