c# 查找字符串中,含指定字符串出现的次数

  public static int ContainCount(string input, string findstr, bool ignoreCase)
        {
            if (ignoreCase)
            {
                input = input.ToLower();

                findstr = findstr.ToLower();
            }

            int count = 0;

            for (int i = 0; (i = input.IndexOf(findstr, i)) >= 0; i=i+findstr.Length)
            {
                count++;
            }

            return count;
        }

你可能感兴趣的:(c# 查找字符串中,含指定字符串出现的次数)