I feel like this should be an easy question, but its totally bugging me. I have a string array, of size 64, called items. I want to write each item of items to a text file, with each value separated by a tab. When I try the following code though, it writes each item + tab, then a new line. How do I get all of the array written onto one line, instead of line by line?
using (System.IO.StreamWriter file = new System.IO.StreamWriter(path1+custFile))
for(int i=0; i<64; i++)
file.WriteLine(items[i].ToString()+"\t");
Results:
1002H0025
Sample test Customer
Foo
Mr
123 FAKE STREET
sAN JOSE
And so on and so on, and I excluded the tabs themselves from the above.
It should be
1002H0025 Sample test Customer Foo Mr 123 FAKE STREET sAN JOSE
You are currently using
WriteLine()inside the loop.Try using
Write()instead.WriteLineoutputs a newline (\n) after it writes to the output.