title: Building an ArrayList in an external class - vb.net
body: <p>I have an <code>ArrayList</code> defined in <code>Class A</code>. Then I want to build  this array in <code>Class B</code> and use it in <code>Class A</code>.</p>
  
  <p>I defined the ArrayList as: </p>
  
  <pre><code>Public arrayList As ArrayList
  </code></pre>
  
  <p>Then, in <code>Class B</code> I do:</p>
  
  <pre><code>Dim trLogkEmpty As New A
  'Loop with strEspece definition
      trLogkEmpty.arrayList.Add(strEspece)
  'End Loop
  </code></pre>
  
  <p>The program throws me this error:</p>
  
  <blockquote>
    <p>NullReferenceException</p>
  </blockquote>
  
  <p>I don't know why, because <code>strEspece</code> has never become null (I tested it). I don't know if there is another reason.</p>
  
  <p>Also, when I loop through the <code>arrayList</code> elements in <code>Class A</code>, I get again <code>NullReferenceException</code>. This is the loop code: </p>
  
  <pre><code>For Each logkNull In Me.arrayElemWithLogkEmpty
      Console.WriteLine(logkNull)
   Next
  </code></pre>
  
  <p>I don't know what happens with the first exception, but the code runs "correctly". In the second exception I guess that is something like I'm loosing the elements values of the array. I don't know how to solve it...any help? I accept different ways to solve it! </p>