I want to extract values of a variable in CSV file from a c# console application.
Variable has unlimited values like it is the position value from a stream when the stream ends variable values also finishes. I have seen many examples on the internet but none of them answers my question.
Here is what I found.
var file = @"C:\SavedBTData.csv";
using (var stream = File.AppendText(file))
{
for (int i = 0; i < ToBT.Count(); i++)
{
BTdata[i] = ToBT[i].ToString();
}
string csvRow = string.Format("{0},{1},{2},{3},{4},{5},{6},{7}", BTdata[0], BTdata[1], BTdata[2], BTdata[3], BTdata[4], BTdata[5], BTdata[6], BTdata[7]);
stream.WriteLine(csvRow);
}
But here in string csvRow line .... I don't know how much values I get from that variable moreover I have to save data in just 1 column.
Anyone with a possible suggestion.