我有一个包含行任意数量的字符串列表。每行的长度为12个字符,我想将其内容打印到文本文件中。这是很容易做的在字符串列表字符之间添加新行中的每一行C#
System.IO.File.WriteAllLines(@".\strings.txt", myList);
现在,我想每6个字符后插入newLine
,有效地加倍列表的计数。
E.g
System.IO.File.WriteAllLines(@".\strings.txt", myList);
// Output from strings.txt
123456789ABC
123456789ABC
// ...
// command to insert newLine after every 6 characters in myList
System.IO.File.WriteAllLines(@".\strings.txt", myListWithNewLines);
// Output from strings.txt
123456
789ABC
123456
789ABC
您可能会感兴趣在['String.Insert(int startIndex,string value)'中](http://msdn.microsoft.com/en-us/library/system.string.insert.aspx) – newfurniturey
请downvoters,添加downvote的原因,我会尝试改进我的问题。 – chwi