title: C# int64 list to byte array and vice versa casting?
body: <p>Please show me optimized solutions for castings:</p>
  
  <p>1)</p>
  
  <pre><code>    public static byte[] ToBytes(List&lt;Int64&gt; list)
      {
          byte[] bytes = null;
  
          //todo
  
          return bytes;
      }
  </code></pre>
  
  <p>2)</p>
  
  <pre><code>    public static List&lt;Int64&gt; ToList(byte[] bytes)
      {
          List&lt;Int64&gt; list = null;
  
          //todo
  
          return list;
      }
  </code></pre>
  
  <p>It will be very helpful to see versions with minimized copying and/or with unsafe code (if it can be implemented). Ideally, copying of data are do not need at all.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>My question is about casting like C++ manner:</p>
  
  <pre><code>__int64* ptrInt64 = (__int64*)ptrInt8;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>__int8* ptrInt8 = (__int8*)ptrInt64
  </code></pre>
  
  <p>Thank you for help!!!</p>