List.Add is changing existing members?

This is a discussion on List.Add is changing existing members? within the C# Programming forums, part of the General Programming Boards category; I'm using the .Add() method of the .NET List to add new members. Trouble is, this seems to be changing ...

centroids.Add(bufferCentroid);
Simply adds a reference to the list, and since you're re-using the same reference, all items in the list point to the same object. What you want to do is actually create new objects (using new).