// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; namespace E { class MainClass { public static void Main(string[] args) { string s = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In commodo. Mauris nec ipsum. Donec tincidunt. Aliquam erat volutpat. Pellentesque aliquam. Donec interdum malesuada arcu. Duis risus posuere."; string[] word = s.Split(" ".ToCharArray()); int ix = 0; string line = ""; while(ix < word.Length) { if((line + 1 + word[ix]).Length > 20) { Console.WriteLine(line); line = ""; } if(line.Length > 0) { line += " "; } line += word[ix]; ix++; } if(line.Length > 0) { Console.WriteLine(line); } } } }