Still new to C# so be gentle :)
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 .ToArray method but it doesnt seem to be working for me. I get an exception
Cannot Implicilty convert type
String[][]tostring[].
I know I am doing something stupid but cant seem to find out what... Any help would be appreciated.
//Import DAT file and format it.
public int[] ImportDat(string path)
{
List<string[]> loadedData = new List<string[]>();
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;
}