title: How to check empty array
body: <p>I am working in VB.net where i have class like below:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I have object of some other class named as "graph" where in constructor of graph class I am calling constructor of vertex class.</p>
  
  <p>I have array of vertex class: Public vertices() As vertex</p>
  
  <p>And redim vertices(2000): resizing array again for some reason.</p>
  
  <p>Now, when i loop the array to check empty value it throws an error:</p>
  
  <p>Object reference not set to an instance of an object. (Since value contains "nothing")</p>
  
  <p>even though i am checking like this, </p>
  
  <pre><code>If (vertices(i).name) Is Nothing Then
              Exit For
          End If
  </code></pre>
  
  <p>How can i check empty element of array?</p>