title: C# Decimal to byte[] and back in C
body: <p>I have a system that stores a decimal value on a Mifare card</p>
  
  <p>The C# decimal value is converted to a byte array of 16 bytes using this code</p>
  
  <pre><code>MemoryStream memStream = new MemoryStream();
  BinaryWriter writer = new BinaryWriter(memStream);
  try
  {
    try
    {
       writer.Write(m_Value);
       tmp = memStream.ToArray();
    }
    finally
    {
       memStream.Close();
    }
  }
  finally
  {
    writer.Close();
  }
  </code></pre>
  
  <p>which gives a 16byte representation.</p>
  
  <p>Now we have a customer which needs to read and convert these 16 bytes back to a decimal number, <strong>but in C</strong></p>
  
  <p>How is this done ?</p>
  
  <p>Can anyone find a definition/spec of the C# byte representation, i cannot</p>