title: Why does List.Clear() also get rid of a class property?
body: <p>I have the following class:</p>
  
  <pre><code>    Public Class ID
          Private sID as List(Of Integer)
  
          Public property IDlist as List(Of Integer)
              Get
                  Return sID
              End Get
              Set(ByVal value as List(Of Integer)
                  sID = value
              End Set
          End Property
      End Class
  </code></pre>
  
  <p>I then do:</p>
  
  <pre><code>    Dim objID as ID
      Dim myList as List(Of Integer)
  
      for i = 0 to 1
          objID = New ID
          MyList.add(1)
          Mylist.add(2)
  
          ID.IDlist = mylist
          mylist.clear
      Next
  </code></pre>
  
  <p>If I insert code to retrieve one of the ID.IDlist properties BEFORE mylist.clear it works fine for both iterations. However, if I try to retrieve the values AFTER the for loop I get nothing.</p>
  
  <p>I found that this code allows me to get the ID.IDlist for both ID objects after for for loop:</p>
  
  <pre><code>    Dim objID as ID
      Dim myList as List(Of Integer)
  
      for i = 0 to 1
          objID = New ID
          mylist = New List(Of Integer)
  
          MyList.add(1)
          Mylist.add(2)
  
          ID.IDlist = mylist
      Next
  </code></pre>
  
  <p>I could be way off here, but it almost seems like ID.IDlist points to the address of mylist and so when mylist is cleared so is ID.Idlist. It seems as though the reason the second block of code works is because I am creating a new list in memory for each ID object and ID.IDlist just points to it... is that right?</p>
  
  <p>Can anyone confirm / explain? I spent like 5 hours on this situation.. ugh</p>
  
  <p>thank you for any explanation!</p>