Edit

Share via


'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.

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