title: C# XOR on two byte variables will not compile without a cast
body: <p>Why does the following raise a compile time error: 'Cannot implicitly convert type 'int' to 'byte':</p>
  
  <pre><code>        byte a = 25;
          byte b = 60;
  
          byte c = a ^ b;
  </code></pre>
  
  <p>This would make sense if I were using an arithmentic operator because the result of a + b could be larger than can be stored in a single byte.</p>
  
  <p>However applying this to the XOR operator is pointless. XOR here it a bitwise operation that can never overflow a byte.</p>
  
  <p>using a cast around both operands works:</p>
  
  <pre><code>byte c = (byte)(a ^ b);
  </code></pre>