title: Foreach/for loop with List<T> won't update properly
body: <p>I'm having some issues with a <code>foreach</code> loop and <code>List&lt;T&gt;</code></p>
  
  <pre><code>foreach (DefenceTerminal defence in DefenceManager.defenceCollection)
  {
      defence.ReadNetworkPacket(packetReader);
      //this is a very simple function that just sets defence.damage = to whatever
      //it properly sends the value and sets it
      //defence.damage is a int
  }
  </code></pre>
  
  <p>when I leave the loop, the value... disappears. (It fails to change)</p>
  
  <p>all values remain unchanged once the loop is left</p>
  
  <p>the list is accessed in the update in a similar fashion.</p>
  
  <p>I have used <code>for</code> loops as an alternative as well, so i guess it is more of a <code>List&lt;T&gt;</code> issue more then anything else. </p>
  
  <p>I would prefer to keep using a list, however. Suggestions?</p>
  
  <p>And here is the very simple function for those who want very simple functions</p>
  
  <pre><code>    public void ReadNetworkPacket(PacketReader packetReader)
      {
          damage = packetReader.ReadInt32();
      }
  </code></pre>
  
  <p>IT works, the list and loop doesn't.</p>
  
  <p>Again: While within the loop Everything works fine, i have checked multiple times, but it doesn't... stick... like it makes its own little personal list to mess with then drops it after its done, which is unhelpful when your trying to update the list. Its a strange idiosyncrasy having to do with List I'm sure.</p>
  
  <p>Other crap:</p>
  
  <pre><code>public static List&lt;DefenceTerminal&gt; defenceCollection = new List&lt;DefenceTerminal&gt;();
  
          for (int i = 0; i &lt; factionCount; i++)
          {
              DefenceTerminal d = new DefenceTerminal();
              for (int j = 0; j &lt; defenceLimit; j++)
              {
                  defenceCollection.Add(d);
              }
          }
  </code></pre>