title: Serializing/Deserializing a standalone integer using protocol buffers
body: <p>Up to now, I've been using Protocol Buffers to serialize and deserialize objects using the code-generated classes.</p>
  
  <p>Now I am attempting to serialize and deserialize a single 64-bit integer. The problem is, I'm getting different results in Java and C#.</p>
  
  <p>Here's how I'm doing it in Java....</p>
  
  <pre><code>private static byte[] convertLongToByteArray(long value) throws IOException {
      int size = CodedOutputStream.computeInt64SizeNoTag(value);
      byte[] buffer = new byte[size];
      CodedOutputStream codedOutputStream = CodedOutputStream.newInstance(buffer);
      codedOutputStream.writeInt64NoTag(value);
      codedOutputStream.flush();
      codedOutputStream.checkNoSpaceLeft();
      return buffer;
  }
  </code></pre>
  
  <p>And here's how I'm doing this in C#, using protobuf.net:</p>
  
  <pre><code>public void SerializeLongValue()
  {
      long n = 9876;
      byte[] memoryBuffer = null;
      using (MemoryStream destination = new MemoryStream())
      {
          ProtoBuf.Serializer.Serialize(destination, n);
          destination.Flush();
          memoryBuffer = destination.ToArray();
      }
  
      using (MemoryStream source = new MemoryStream(memoryBuffer))
      {
          long result = ProtoBuf.Serializer.Deserialize&lt;long&gt;(source);
          Assert.AreEqual(n, result);
      }
  }
  </code></pre>
  
  <p>The java code converted the number <code>9876</code> to <code>[0x94, 0x4D]</code></p>
  
  <p>The C# code converted the number <code>9876</code> to <code>[0x08, 0x94, 0x4D]</code></p>
  
  <p>How do I do this so that both <code>com.google.protobuf</code> and <code>protobuf.net</code> produce identical outputs?</p>