title: Can IntPtr be cast into a byte array without doing a Marshal.Copy?
body: <p>I want to get data from an IntPtr pointer into a byte array.  I can use the following code to do it:</p>
  
  <pre><code>IntPtr intPtr = GetBuff();
  byte[] b = new byte[length];
  Marshal.Copy(intPtr, b, 0, length);
  </code></pre>
  
  <p>But the above code forces a copy operation from IntPtr into the byte array. It is not a  good solution when the data in question is large.</p>
  
  <p>Is there any way to cast an IntPtr to a byte array?  For example, would the following work:</p>
  
  <p><code>byte[] b = (byte[])intPtr</code></p>
  
  <p>This would eliminate the need for the copy operation.</p>
  
  <p>Also: how can we determine the length of data pointed to by IntPtr?</p>