title: Copy byte array to another byte array in C#
body: <p>There are two byte arrays which are populated with different values.</p>
  
  <pre><code>byte[] Array1 = new byte[5];
  byte[] Array2 = new byte[5];
  </code></pre>
  
  <p>Then, I need <code>Array1</code> to get exactly the same values as <code>Array2</code>.</p>
  
  <p>By typing <code>Array1 = Array2</code> I would just set references, this would not copy the values.</p>
  
  <p>What might be the solution?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>All answers are good and all solutions work. The code from the first solution looks visually more descriptive for my particular case.</p>
  
  <blockquote>
    <p>Array1 = Array2.ToArray();</p>
  </blockquote>
  
  <p>and </p>
  
  <blockquote>
    <p>Array1.CopyTo(Array2, 0);</p>
  </blockquote>
  
  <p>as well as </p>
  
  <blockquote>
    <p>Buffer.BlockCopy(Array2, 0, Array1, 0, 5);</p>
  </blockquote>