title: C# List to Array Problem
body: <p>Still new to C# so be gentle :)</p>
  
  <p>I have some code which reads in a CSV file and stores the output in a List. I used a List instead of an Array as the number of entries in the CSV is undetermined. Once the List is created from the file I then want to pass it to a Shell sort method as this is the purpose of the program. To do this I first want to convert the list to an array of integers. I have tried the <code>.ToArray</code> method but it doesnt seem to be working for me. I get an exception </p>
  
  <blockquote>
    <p>Cannot Implicilty convert type <code>String[][]</code> to <code>string[]</code>. </p>
  </blockquote>
  
  <p>I know I am doing something stupid but cant seem to find out what... Any help would be appreciated.</p>
  
  <pre><code>//Import DAT file and format it.
  public int[] ImportDat(string path)
  {
      List&lt;string[]&gt; loadedData = new List&lt;string[]&gt;();
  
      loadedData.Clear();
  
      try
      {
          using (StreamReader readCSV = new StreamReader(path))
          {
              string line;
              string[] row; 
  
              while ((line = readCSV.ReadLine()) != null)
              {
                  row = line.Split(',');
                  loadedData.Add(row);
              }
          }
      }
      catch
      {
          MessageBox.Show("Import Failed. Please check the file is in the same folder as the executable");
      }
  
      string[] MyArray = loadedData.ToArray();
  
      //temp Array to return a value
      int[] numbers = new int[5] { 1, 2, 3, 4, 5 };
  
      return numbers;
  }
  </code></pre>