我在 VB.net 工作,我的课程如下:
Public Class vertex
Public wasVisited As Boolean
Public name, type As String
Public x_pos, y_pos As Double
Public Sub New(ByVal x_pos As Double, ByVal y_pos As Double, ByVal name As Integer, ByVal type As String)
Me.x_pos = x_pos
Me.y_pos = y_pos
Me.name = name
Me.type = type
wasVisited = False
End Sub
End Class
我有一些名为“图”的其他类的对象,在图类的构造函数中,我正在调用顶点类的构造函数。
我有顶点类数组: Public vertices() As vertex
并且 redim vertices(2000): 出于某种原因再次调整数组大小。
现在,当我循环数组以检查空值时,它会引发错误:
你调用的对象是空的。(因为值包含“无”)
即使我这样检查,
If (vertices(i).name) Is Nothing Then
Exit For
End If
如何检查数组的空元素?