Udostępnij za pośrednictwem


'IsNot' operand of type '<typeparametername>' can be compared only to 'Nothing' because '<typeparametername>' is a type parameter with no class constraint

A type parameter is used as an operand for the IsNot Operator when the type parameter is defined without either the Class (Visual Basic) keyword or a specific class name in its constraint list.

IsNot compares two reference types to determine whether they point to different object instances in memory. It cannot take an operand that is not a reference type unless the other operand is Nothing (Visual Basic).

Error ID: BC32097

To correct this error

  • If you can require that the type argument supplied to this type parameter always be a reference type, add either the Class keyword or a specific class name to the constraint list for the type parameter.

  • If you cannot require that the type argument supplied to this type parameter always be a reference type, remove it from the IsNot expression. You cannot compare it to other reference types with the IsNot operator.

See Also

Concepts

Generic Types in Visual Basic

Value Types and Reference Types

Comparison Operators in Visual Basic

Reference

Type List