title: Copy 2D Array in C#
body: <p>I have a code that stored the data to a temporary array.  </p>
  
  <pre><code>string filename = openFileDialog1.FileName;
  string[] line = File.ReadAllLines(filename);
  using (var reader2 = File.OpenText(@filename))
  {
      for (int i = 0; i &lt; line.Length; i++)
      {
          string lines = reader2.ReadLine();
          var data = lines.Split(',');
          double[,] arrayTemp = new double[line.Length, 2];
          arrayTemp[i, 0] = double.Parse(data[0]);
          arrayTemp[i, 1] = double.Parse(data[1]);
      }
      Array.Copy(arrayTemp, GlobalDataClass.dDataArray, line.Length); //error the name "arrayTemp" does not exist in the current context.
  } 
  </code></pre>
  
  <p>Since 2d array is not resizable and I want my global array to be flexible,so I use the <code>Array.Copy</code> method to copy the temp array to the Global class array. However I got an error as commented in my code above.</p>
  
  <p>My question is how to copy the <code>tempArray</code> to the global class array.
  Any idea how to fix this?</p>