How does stream.write work? : <p>Basically, why does this work?</p>

<pre><code>System.IO.Stream stream = new MemoryStream();
int a = 4;
byte[] barray = new byte[a];
stream.Write(barray, 0, Marshal.SizeOf(a));
</code></pre>

<p>When this doesn't:</p>

<pre><code>System.IO.Stream stream = new MemoryStream();
int a = 3;
byte[] barray = new byte[a];
stream.Write(barray, 0, Marshal.SizeOf(a));
</code></pre>

<p>This is the error I get:</p>

<pre><code>The offset and length were greater than allowed for the matrix, or the number is greater than the number of elements from the index to the end of the source collection.
</code></pre>
