Type parameter with a 'Structure' constraint cannot be used as a constraint

A type parameter with a Structure constraint is used as the constraint for another type parameter.

The Structure constraint requires that the type argument passed to its type parameter be a value type. However, a value type cannot be implemented or inherited, so it is not meaningful to use it as a constraint, which would require the other type parameter to implement it or inherit from it.

The only meaningful interpretation of this situation is that both type arguments must be of the exact same type. If that is the case, your generic type needs only one type parameter.

The following statement can generate this error.

Class c1(Of t1 As Structure, t2 As t1)

The type passed to t2 cannot implement or inherit the type passed to t1, because the type passed to t1 must be a value type.

Error ID: BC32114

To correct this error

  • Remove the type parameter constrained to Structure from the constraint list on the other type parameter.

  • If both type parameters require the same value type, define the generic type with only one type parameter.

See Also

Concepts

Generic Types in Visual Basic

Value Types and Reference Types

Reference

Type List

Structure (Visual Basic)