Public Class EquipmentNode
'...
End Class
Private Sub DoWork()
Dim node As TreeNode = _contextNode
If node is EquipmentNode ' Does not work
if node is TypeOf EquipmentNode ' Does not work
End Sub
How can I see if the node is the same type. Right now I'm just casting it and seeing if the result is null, but I want to make use of the "Is" operator.
The Visual Basic Is Operator, (unlike the C#'s is operator), does not tell you about the object's type, but rather whether two objects variables refer to the same actual object instance.
The Is operator determines if two object references refer to the same object
This will not tell you whether the object is a specific type.
To compare types, you'd use:
If TypeOf node Is EquipmentNode Then
The Is
operator in VB doesn't - as is
in C# - check if an object is of a certain type, it does the same job as C#'s ReferenceEquals()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With