I'm having trouble saving a 2D array string[,] to a csv file in C#. I want each element to be in its own cell when I open the .csv file in Excel but with this code everything ends up in one column. What should I change in order to have every element in its own cell?
public static void Main(string[] args)
{
string[,] array = new string[2, 5];
array[0, 0] = "ID";
array[0, 1] = "Turns";
array[0, 2] = "Forward Results";
array[0, 3] = "Backward Results";
array[0, 4] = "Trainings";
array[1, 0] = "SEL-HYS-001";
array[1, 1] = "5";
array[1, 2] = "100%";
array[1, 3] = "100%";
array[1, 4] = "1";
StreamWriter sw = File.CreateText("outputText.csv");
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 5; j++)
{
sw.Write(array[i, j] + ";");
}
sw.Write("\n");
}
sw.Flush();
sw.Close();
Console.WriteLine("Success!");
}