Arrays to txt file | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 20

Arrays to txt file

How to write three separate arrays into 1 txt file? By lines.

8th Apr 2017, 12:28 AM
Illusive Man
Illusive Man - avatar
3 Answers
+ 3
using (System.IO.StreamWriter file = new System.IO.StreamWriter("filename.txt", true)) { foreach (string s : array) { file.WriteLine(s); } } and write 2 additional foreach loops for the other arrays
8th Apr 2017, 1:07 AM
Edward
+ 19
@Edward both acceptable. First idea was "one line per array" but it seems that reading will be easier with "line per item"
8th Apr 2017, 12:40 AM
Illusive Man
Illusive Man - avatar
+ 1
do u want one line per array or one line per item in each array
8th Apr 2017, 12:34 AM
Edward