List item in another class disappears when removing as passed instance

I’m currently freakin out a little.
I’m passing a List to a method of another class and in that class I’m using a different variable name (encapsulated). But here it is:
When I remove an item from the list within the method the item disappears in the other variable as well!

Any suggetions what I’m doing wrong?

Here the code snippet:

public partial class Form1 : Form
{
   List<Vector> polygonPoints = new List<Vector>();

   private void panel1_Paint(object sender, PaintEventArgs e)
   {
      // Create Convex Hull of polygon Set
         QuickHull qh = new QuickHull();

      // here I pass the list to a method in the class QuickHull
      // here polygonPoints.Count = 5
         List<Vector> hullOfPoints = qh.quickHull(polygonPoints);
      // at this point I get polygonPoints.Count = 3

         ...
   }
}

different class QuickHull:

class QuickHull
{
    public List<Vector> quickHull(List<Vector> points)
    {
        List<Vector> convexHull = new List<Vector>();
        ...
        Vector A = points[minPoint];
        Vector B = points[maxPoint];

        convexHull.Add(A);
        convexHull.Add(B);

        // at this point 'polygonPoints' also looses these items
        points.Remove(A);
        points.Remove(B);

        ...
     }
}

I really don’t know what to do because this was working all the time but from one moment to the other its not working anymore.

I’d really appreciate every suggetion.

Thanks in advance.


Download list.item.in.another.class.disappears.when.removing.as.passed.instance.zip
Direct Link


Download


Download list.item.in.another.class.disappears.when.removing.as.passed.instance.zip
Mediafire


Download


Download list.item.in.another.class.disappears.when.removing.as.passed.instance.zip
Filerio


Download

Both comments and pings are currently closed.

Comments are closed.