title: Byte array to int C#
body: <p>I am triyng to convert byte array into an int value
  however I am getting an exception:</p>
  
  <blockquote>
    <p>"Destination array is not long enough to copy all the items in the
    collection. Check array index and length."</p>
  </blockquote>
  
  <p>the exception is on line:    </p>
  
  <pre><code>int length = BitConverter.ToInt32(bytes_length, 0);
  </code></pre>
  
  <p>byte _length contain the value (0x00,0x09);</p>
  
  <p>here is my code:</p>
  
  <pre><code>byte[] bytes_length = new byte[Value_of_length];                   
  //copy the byte byte array to the correct length.
  Array.Copy(data, Place_of_length, bytes_length, 0,bytes_length.Length
  int length = BitConverter.ToInt32(bytes_length, 0);
  </code></pre>