title: When adding a new object to the list all the objects already added previously are overwritten
body: <p>This is the list that must reference the open classes.</p>
  
  <pre><code>readonly List&lt;object&gt; openedClasses = new List&lt;object&gt;();
  </code></pre>
  
  <p>Here is where I create classes and add the list.</p>
  
  <pre><code>var employees = myWs.ReturnListEmployee(guid);
  foreach (Api.EmployeeData employee in employees)
  {
       openedClasses.Add(new MyClass(pendingSchedules[0], employee));
  }
  </code></pre>
  
  <p>My class and its constructor:</p>
  
  <pre><code>class MyClass
  {
      public Schedule schedule;
  
      public MyClass(Schedule schedule, Api.EmployeeData employee)
      {
          // the "schedule.EmployeeData" it is constantly changed
          this.schedule = schedule;
          this.schedule.EmployeeData = employee;
      }
  }
  </code></pre>
  
  <p>My problem is: Every foreach loop all values previously added to the list are overwritten by the most recently added class.</p>
  
  <p>I've tried all the solutions I found on the internet and made the checks, the class is not static and I removed each static method and static field that was called on it (just to make sure), the list I have created with and without the readonly as list of "object" and as a list of "MyClass".</p>
  
  <p>With:</p>
  
  <pre><code>openedClasses.Add(new MyClass(pendingSchedules[0], employee));
  </code></pre>
  
  <p>And with:</p>
  
  <pre><code>var myClass = new MyClass(pendingSchedules[0], employee);
  openedClasses.Add(myClass);
  </code></pre>