当前位置 : 主页 > 编程语言 > c语言 >

vb.net – Visual Basic – 是运算符

来源:互联网 收集:自由互联 发布时间:2021-06-24
Public Class EquipmentNode '...End ClassPrivate Sub DoWork() Dim node As TreeNode = _contextNode If node is EquipmentNode ' Does not work if node is TypeOf EquipmentNode ' Does not workEnd Sub 如何查看节点是否为同一类型.现在我
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

如何查看节点是否为同一类型.现在我只是将它投射并查看结果是否为null,但我想使用“Is”运算符.

Visual Basic Is Operator(与 C#’s is operator不同)不会告诉您对象的类型,而是两个对象变量是否引用相同的实际对象实例.

The Is operator determines if two object references refer to the same object

这不会告诉您对象是否是特定类型.

要比较类型,您可以使用:

If TypeOf node Is EquipmentNode Then
网友评论