Udostępnij za pośrednictwem


'Is' operand of type 'typename' can only be compared to 'Nothing', because 'typename' is a nullable type

A variable declared as nullable has been compared to an expression other than Nothing by using the Is operator.

Error ID: BC32127

To correct this error

  • To compare a nullable type to an expression other than Nothing by using the Is operator, call the GetType method on the nullable type and compare the result to the expression, as shown in the following example.

    Dim number? As Integer = 5
    
    If number IsNot Nothing Then
      If number.GetType() Is Type.GetType("System.Int32") Then 
    
      End If
    End If
    

See Also

Concepts

Nullable Value Types

Reference

Is Operator (Visual Basic)