title: Adding objects in a List
body: <p>I want to add objects in a <code>List &lt;T&gt;</code> when I select an item from a combobox, named cmbMaxim. The problem is I obtain a list with the same object (last object added). It's seems like new operator won't work and I obtain a reference to the same object. Here is the code:</p>
  
  <pre><code>public partial class Form1 : Form
  {
      List&lt;Varianta&gt; lvar = new List&lt;Varianta&gt;();
      int contor = 0;
      public Form1()
      {
          InitializeComponent();
      }
  
  
      private void cmbMaxim_SelectedIndexChanged(object sender, EventArgs e)
      {
          int[] vgen = new int[6];
          int vmax = Convert.ToInt32(cmbMaxim.Text);
          for (int i0 = 1; i0 &lt; vmax - 4; i0++)
              for (int i1 = i0 + 1; i1 &lt; vmax - 3; i1++)
                  for (int i2 = i1 + 1; i2 &lt; vmax - 2; i2++)
                      for (int i3 = i2 + 1; i3 &lt; vmax - 1; i3++)
                          for (int i4 = i3 + 1; i4 &lt; vmax; i4++)
                              for (int i5 = i4 + 1; i5 &lt; vmax + 1; i5++)
                              {
                                  Varianta var = new Varianta();
                                  vgen[0] = i0;
                                  vgen[1] = i1;
                                  vgen[2] = i2;
                                  vgen[3] = i3;
                                  vgen[4] = i4;
                                  vgen[5] = i5;
                                  contor++;
                                  var.Var = vgen;
                                  var.Index = contor;
                                  lvar.Add(var);
                              }
      }
  }
  </code></pre>
  
  <p>Class Varianta is:</p>
  
  <pre><code>class Varianta
  {
      int[] var = new int[6];
      int index;
      int scor=0;
      int eliminate=0;
  
      public int Scor
      {
          get 
          { 
              return scor;
          }
          set 
          { 
              scor = value; 
          }
      }
  
      public int Index
      {
          get 
          { 
              return index; 
          }
          set 
          { 
              index = value; 
          }
      }
  
  
      public int [] Var
      {
          get 
          { 
              return var; 
          }
          set 
          { 
              var = value; 
          }
      }
  }
  </code></pre>
  
  <p>What is wrong?</p>