title: Generic Swap difficulty
body: <p>I'm coming from C++ where it's easy to do something like this:</p>
  
  <pre><code>template&lt;class T&gt;
  void Swap(T &amp;a, T &amp;b)
  {
    T temp = a;
    a = b;
    b = temp;
  }
  </code></pre>
  
  <p>and then use it to swap values in a container:</p>
  
  <pre><code>std::vector&lt;int&gt; someInts;
  someInts.push_back(1);
  someInts.push_back(2);
  
  Swap(someInts[0], someInts[1]);
  </code></pre>
  
  <p>However, upon attempting to do the same thing in C#</p>
  
  <pre><code>void Swap&lt;T&gt;(ref T a, ref T b)
  {
          T temp = a;
      a = b;
      b = temp;
  }
  </code></pre>
  
  <p>I get the error "property or indexer may not be passed as an out or ref parameter"</p>
  
  <p>Why is this and how can I overcome it?</p>
  
  <p>Many thanks</p>