using System.Collections.Generic;
public static List<string> SplitStringOptimized(string input, int maxLength)
List<string> result = new List<string>();
string[] words = input.Split(' ');
while (index < words.Length)
string currentLine = words[index];
while (index < words.Length && (currentLine + " " + words[index]).Length <= maxLength)
currentLine += " " + words[index];
public static void Main(string[] args)
string input = "priya patel & khushbu Faldu & Nilam Gadhiya & jeremy Leo & Jemes <Trustname>";
string[] words = input.Split('<');
List<string> substrings = SplitStringOptimized(words[0], maxLength);
substrings.Add("<{words[1]}");
foreach (string substring in substrings)
Console.WriteLine(substring);