public static int WordsOverlapLength(string word1, string word2, CompareStringsDelegate comparer) { int length1 = word1.Length; int length2 = word2.Length; int maxOverlap = System.Math.Min(length1, length2); for (int i = maxOverlap; i > 0; i--) { string suffixOf1 = word1.Substring(length1 - i, i); string prefixOf2 = word2.Substring(0, i); if (comparer(suffixOf1, prefixOf2)) { return(i); } } return(0); }
public static int WordsOverlapLength(string word1, string word2, CompareStringsDelegate comparer) { int length1 = word1.Length; int length2 = word2.Length; int maxOverlap = System.Math.Min(length1, length2); for (int i = maxOverlap; i > 0; i--) { string suffixOf1 = word1.Substring(length1 - i, i); string prefixOf2 = word2.Substring(0, i); if (comparer(suffixOf1, prefixOf2)) { return i; } } return 0; }