string[] tests = new[] { "oo", "ooo", "oooo" };
int maxLength = tests.Select(v => v.Length).Max();
foreach (string s in tests)
Console.WriteLine($"\"{s}\"".PadRight(maxLength + 2) + $" -> {s.Count("oo")}");
public static int Count (this string s, string substr, StringComparison strComp = StringComparison.CurrentCulture)
int count = 0, index = s.IndexOf(substr, strComp);
index = s.IndexOf(substr, index + substr.Length, strComp);