title: C# : Changing copy of array changes array itself
body: <p>I have a very basic question in C#. So I have an array of int called m_permutation (property of a class), and in a method of the class I have the following code:</p>
  
  <pre><code>    int[] newPermutation = new int[m_permutation.Length];
      newPermutation = m_permutation;
      newPermutation[0] = 5;
  </code></pre>
  
  <p>I am confused as to why m_permutation is also changed in this code, and how can I fix it ?</p>
  
  <p>I understand that I can initialize newPermutation via a loop for, to get the same values of m_permutation, and that fixes it. However, can somebody explain why this happens, and what is the best fix ?</p>
  
  <p>Thank you,</p>
  
  <p>Bogdan</p>