Explain this use of XOR in this function?
<p>I saw this code snippet that was used to solve the ol' "Find the one number in an array that does not have a duplicate." question. I have been looking at this for a while this morning, but can not nail down exactly how it is doing it.</p>

<p>I don't understand how k always ends up holding the value of the non-duplicate.  Can anyone explain how this works?</p>

<pre><code>  static void Main(string[] args)
  {
     int[] list = { 3,6,9,12,3,6,9 };
     int k = 0;


     for (int i = 0; i &lt; list.Length; i++)
     {
        k = k ^ list[i];
     }

     Console.WriteLine(k);
  }
</code></pre>
