임의의 수의 줄이 포함 된 문자열 목록이 있습니다. 각 줄의 길이는 12 자이며 내용을 텍스트 파일로 인쇄하려고합니다. 이것은 지금, 나는 효과적으로 목록의 카운트 수를 두 배로, 매 6 자 후 newLine
을 삽입 할문자열 목록의 모든 줄에있는 문자 사이에 개행을 추가합니다. C#
System.IO.File.WriteAllLines(@".\strings.txt", myList);
을하고 매우 간단합니다. 당신의 세트 예컨대
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
당신이 관심이있을 수도를 in ['String.Insert (int startIndex, string value)' ] (http://msdn.microsoft.com/en-us/library/system.string.insert.aspx) – newfurniturey
downvoters, downvote에 대한 이유를 추가하십시오 및 내 질문을 향상 시키려고합니다. – chwi