title: Working with byte arrays in C#
body: <p>I have a byte array that represents a complete TCP/IP packet.  For clarification, the byte array is ordered like this:</p>
  
  <p>(IP Header - 20 bytes)(TCP Header - 20 bytes)(Payload - X bytes)</p>
  
  <p>I have a <code>Parse</code> function that accepts a byte array and returns a <code>TCPHeader</code> object.  It looks like this:</p>
  
  <pre><code>TCPHeader Parse( byte[] buffer );
  </code></pre>
  
  <p>Given the original byte array, here is the way I'm calling this function right now.</p>
  
  <pre><code>byte[] tcpbuffer = new byte[ 20 ];
  System.Buffer.BlockCopy( packet, 20, tcpbuffer, 0, 20 );
  TCPHeader tcp = Parse( tcpbuffer );
  </code></pre>
  
  <p>Is there a convenient way to pass the TCP byte array, i.e., bytes 20-39 of the complete TCP/IP packet, to the <code>Parse</code> function without extracting it to a new byte array first?</p>
  
  <p>In C++, I could do the following:</p>
  
  <pre><code>TCPHeader tcp = Parse( &amp;packet[ 20 ] );
  </code></pre>
  
  <p>Is there anything similar in C#?  I want to avoid the creation and subsequent garbage collection of the temporary byte array if possible.</p>