title: An exam exercise about swapping items in an array in C#
body: <p>So the exam question is this:</p>
  
  <blockquote>
    <p>Write a method using the method header below. </p>
  
  <pre><code>public void Reverse( double [] values, int start, int finish){  
  </code></pre>
    
    <p>This method will reverse the elements in an array between a lower
    index position and an upper index position.</p>
    
    <p>So given the following array declaration</p>
  
  <pre><code>double [] data = {8.5, 12.0, 23.2, 18.0, 15.5, 5.0, 10.5};
  </code></pre>
    
    <p>following a call to the method <code>Reverse(data, 2, 5);</code> the contents of
    data would be </p>
  
  <pre><code>{8.5, 12.0, 5.0, 15.5, 18.0, 23.2, 10.5}
  </code></pre>
    
    <p>Assume that you have already written a method called swap that swaps
    two elements in an array; the elements identified by the two index
    values passed as parameters:</p>
  
  <pre><code>Swap(array, oneIndex, otherIndex)
  </code></pre>
  </blockquote>
  
  <p>I answered it like this:</p>
  
  <pre><code>public void Reverse( double [] values, int start, int finish){  
  
  do {
      Swap(values, int start, int finish);
      }
      start++;
      finish--;
  }
  while (start &lt; finish)
  </code></pre>
  
  <p>I think my answer is not correct but I cannot think of anything else. <code>Swap()</code> method already does everything. Anyone can correct me? Thanks</p>