title: C# binary writer ushort bytes order
body: <p>I have a server side app written in D and my client app is written in C#. I use BinaryWriter for communication between them but I have a problem with the byte order.</p>
  
  <p>Actually the order of bytes is not the same, example :</p>
  
  <p>C# Client:</p>
  
  <pre><code>MemoryStream ms = new MemoryStream();
  BinaryWriter writer = new BinaryWriter(ms);
  writer.Write((ushort)0x01);
  writer.Write("test");
  </code></pre>
  
  <p>Client Output:</p>
  
  <pre><code>[1, 0, 4, 116, 101, 115, 116]
  </code></pre>
  
  <p>Server output:</p>
  
  <pre><code>[0, 1, 0, 4, 116, 101, 115, 116]
  </code></pre>
  
  <p>For the client the first 2 bytes have been inverted and the string in my server app is encoded with <code>ushort</code> for length, it is possible to 'modify' the behavior of the BinaryWriter or do I have to create my own implementation?</p>
  
  <p>Edit: Server side the packet serializer: <a href="https://github.com/Adwelean/EmperadorServer/blob/master/source/vendor/cerealed/cerealiser.d" rel="nofollow">https://github.com/Adwelean/EmperadorServer/blob/master/source/vendor/cerealed/cerealiser.d</a></p>