using System.Globalization;
public static void Main()
Console.WriteLine(StringContainsAnother("Langley", "City of Langley"));
Console.WriteLine(StringCompare("Langley", "City of Langley"));
private static double StringCompare(string a, string b)
if ((a.Length == 0) || (b.Length == 0))
double maxLen = a.Length > b.Length ? a.Length : b.Length;
int minLen = a.Length < b.Length ? a.Length : b.Length;
for (int i = 0; i <= minLen - 1; i++)
return sameCharAtIndex / maxLen * 100;
private static bool StringContainsAnother(string a, string b)
if (!string.IsNullOrEmpty(a) && !string.IsNullOrEmpty(b))
return a.ToLower().Contains(b.ToLower()) || b.ToLower().Contains(a.ToLower());