title: Why does Guid.ToByteArray() order the bytes the way it does?
body: <p>When you call <code>ToByteArray()</code> on a GUID in .NET, the ordering of the bytes in the resulting array is not what you'd expect as compared to the string representation of the GUID.  For example, for the following GUID represented as a string:</p>
  
  <pre><code>11223344-5566-7788-9900-aabbccddeeff
  </code></pre>
  
  <p>The result of <code>ToByteArray()</code> is this:</p>
  
  <pre><code>44, 33, 22, 11, 66, 55, 88, 77, 99, 00, AA, BB, CC, DD, EE, FF
  </code></pre>
  
  <p>Note that the order of the first four bytes is reversed.  Also bytes 4 and 5 are swapped and bytes 6 and 7 are swapped.  But the final 8 bytes are in the same order they're represented as in the string.</p>
  
  <p>I understand that this is occurring.  What I would like to know is why .NET handles it this way.</p>
  
  <p>For reference, you can see some discussion and confusion about this (incorrect attributed to Oracle databases) <a href="https://stackoverflow.com/questions/2667740/convert-byte-array-from-oracle-raw-to-system-guid">here</a> and <a href="https://stackoverflow.com/questions/7289734/convert-from-oracles-raw16-to-nets-guid">here</a>.</p>