Udostępnij za pośrednictwem


Constraint '<constraint1>' conflicts with the indirect constraint '<constraint2>' obtained from the type parameter constraint '<typeparameter1>'

A generic type is declared with conflicting constraints due to a combination of direct and indirect constraints.

The following statement can generate this error.

Public Class testClass(Of t1 As {Structure, t2}, t2 As Class)

The direct constraint Structure and the indirect constraint Class cause a conflict for type parameter t1, 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: BC32110

To correct this error

  • Change the type parameter constraints to avoid conflicting constraints.

See Also

Concepts

Generic Types in Visual Basic

Value Types and Reference Types

Reference

Type List

Structure (Visual Basic)

Class (Visual Basic)