I tried to export an 2-D array from c# to a csv file but last several rows are missing in the csv file.I don't know where the problem is in my code.
First,I'd like to know if my code is not correct?
Second,is it possible to add a title for each row in the csv file .
Thanks in advance
Here is an example of my array in c#
string[,] array=new string[]{{2000,2},{2001,4}}
I want to a result like this in csv file with title
Date C1
2000 2
2001 4
My code:
var outfile=new.streamwriter(@"fileadress.csv");
for(int i=0;i<array.GetUpperbound(0);i++)
{
string content="";
for(int j=0;j<array.GetUpperbound(1);j++)
{
content+= array[i,j]+";";
}
outfile.WriteLine(content);
}
StreamWriters areIDisposable, so you shouldDispose()them when you've finished...