提供的是一种思路,和具体语言无关。
string test = "good good study day day up"; string r = test.Replace("oo",""); int num = (test.Length - r.Length) /"oo".length; Console.WriteLine(num);