title: VB.Net: Adding to a List While Iterating
body: <p>I am trying to figure out a way to add to a list that's being iterated through... </p>
  
  <p>Example Code (Calling <code>test()</code>:</p>
  
  <pre><code>Dim listOfString As New List(Of String)
  
  Public Sub test()
      For Each aString in listOfString
            getNumber(aString)
       Next
  End Sub
  
  Public Sub getNumber(theString as String)
       'Does Something
       listOfString.add(Something)
  End Sub
  </code></pre>
  
  <p>My goal is to continue to add elements onto the end of <code>listOfString</code> while continuing to iterate through it until it gets to the end. I'm getting a <code>Collection was modified; enumeration operation may not execute</code> error on my actual code. Thanks for the time!</p>