using System; using System.Collections.Generic; using System.Linq; public class Test { public static IEnumerable getAllSubstrings(string word) { return from charIndex1 in Enumerable.Range(0, word.Length) from charIndex2 in Enumerable.Range(0, word.Length - charIndex1 + 1) where charIndex2 >= 2 select word.Substring(charIndex1, charIndex2); } public static void Main() { var list = new List() { "ToCommondays","MonCommonday_","TuesCommonda","WednesCommon_day" }; string shortest = list.OrderBy(s => s.Length).First(); IEnumerable shortestSubstrings = getAllSubstrings(shortest) .OrderByDescending(s => s.Length); var other = list.Where(s => s != shortest).ToArray(); string longestCommonIntersection = string.Empty; foreach (string subStr in shortestSubstrings) { bool allContains = other.All(s => s.Contains(subStr)); if (allContains) { longestCommonIntersection = subStr; break; } } Console.Write("longestCommonIntersection=" + longestCommonIntersection); } }