I need some help. I have a method that should output a txt file with the contents of a list(each item on a line). The list items are string arrays. The problem is that when I call string.Join it returns the literal string "System.String[]" instead of the actual concatenated string. I watched it in the debugger and the list and its arrays have the correct strings. Any idea how I can get the actual string so it can be written in the txt file?
Here is my code :
public void myMethod()
{
List<Array> list = new List<Array>();
for (int i = 0; i < myGrid.Rows.Count; i++)
{
string[] linie = new string[3];
linie[0] = myGrid.Rows[i].Cells[1].Value.ToString();
linie[1] = myGrid.Rows[i].Cells[3].Value.ToString();
linie[2] = myGrid.Rows[i].Cells[2].Value.ToString();
{
list.Add(linie);
}
}
string path = "S:\\file.txt";
StreamWriter file = new System.IO.StreamWriter(path);
foreach (Array x in list)
{
string s = string.Join(",", x);
file.WriteLine(s);
}
file.Close();
}
string.Concat(",", x)?Arraytostring[]and it should work fine.