public static void Main()
Console.WriteLine(SplitToMaxLength("Hello World", 10));
Console.WriteLine(SplitToMaxLength("abcdefghijklmnopqrstuvwxyz", 20));
Console.WriteLine(SplitToMaxLength("abcdefghijklmnopqrstuvwxyz", 8));
public static string SplitToMaxLength(string s, int maxLength)
if (string.IsNullOrEmpty(s) == false && maxLength > 1 && s.Length > maxLength)
var sb = new StringBuilder();
var splitLength = (int)(Math.Floor(maxLength / (double)2) - 1);
sb.Append(s.Substring(0, splitLength));
sb.Append(s.Substring(s.Length - splitLength, splitLength));