using System.Collections.Generic;
List<string> randomStrings = new List<string>{"string ends", "ds and another", "her string begins", "but what wi", "will"};
string combinedString = CombineStrings(randomStrings);
Console.WriteLine(combinedString);
static string CombineStrings(List<string> strings)
if (strings == null || strings.Count == 0)
string combinedString = strings[0];
for (int i = 1; i < strings.Count; i++)
string currentString = strings[i];
int matchIndex = GetMatchIndex(combinedString, currentString);
combinedString += currentString.Substring(matchIndex);
combinedString += " " + currentString;
static int GetMatchIndex(string str1, string str2)
int minLength = Math.Min(str1.Length, str2.Length);
for (int i = 0; i < minLength; i++)
if (str1.EndsWith(str2.Substring(0, i + 1)))