For what it's worth, here's a single-line LINQ:
string newline = "How to insert newline character after ninth word of(here) the string such that the remaining string is in next line";
string lines = string.Join(Environment.NewLine, newline.Split()
.Select((word, index) => new { word, index})
.GroupBy(x => x.index / 9)
.Select(grp => string.Join(" ", grp.Select(x=> x.word))));
Result:
How to insert newline character after ninth word of(here)
the string such that the remaining string is in
next line
source
share