title: C# byte[] to long and back
body: <p>I want to convert a given byte array to an int. Then I want to reverse the process. That is I want to get back the original byte array from that int.
  I thought something like this would have worked:</p>
  
  <pre><code>byte[] myBytes = { 0, 0, 0, 32 };
  if (BitConverter.IsLittleEndian)
      Array.Reverse(myBytes);
  int i = BitConverter.ToInt32(myBytes, 0);
  Console.WriteLine("int: {0}", i); // Output: 32
  
  byte[] newBytes = BitConverter.GetBytes(i);
  Console.WriteLine("byte array: " + BitConverter.ToString(newBytes));
  // Outputs: 20-00-00-00
  </code></pre>
  
  <p>So it doesn't give me back the original byte array. What am I doing wrong?</p>