title: Altering a remove method to take an element from an array and moving the last value in its place
body: <p>As the title suggest, in C# I'm trying to alter this remove method to take the last item in an array and move it in place of the value that was removed.  This way when you remove an element, it doesn't have to take each and every individual number and move it up a space.</p>
  
  <p>Here's my current code:</p>
  
  <pre><code>        public override void remove(ref T item)
      {
          if (next == 0)
          {
          }
          else
          {
              //find value, if it exists
              for (int i = 0; i &lt; next; i++)
              {
                  if (item.Equals(list[i]))
                  {
                      for (int j = i; j &lt; next; j++) list[j] = list[j + 1];
                      next--;
                      break;
                  }
              }
          }
      }
  </code></pre>
  
  <p>Any help at all would be appreciated.</p>
  
  <p>Here's my code for inserting the values into the array.</p>
  
  <pre><code>{
          UnorderedArrayList&lt;int&gt; u = new UnorderedArrayList&lt;int&gt;();
          u.print();
          int var = 5;
          u.insert(ref var);
          var = 12;
          u.insert(ref var);
          var = 2;
          u.insert(ref var);
          var = 29;
          u.insert(ref var);
          u.print();
          var = 5;
          u.remove(ref var);
          u.print();
      }
  </code></pre>