查看第二个參数在第一个參数中出现的次数

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace testfour
{
    class Program
    {
        static void Main(string[] args)
        {
            MyClass myclass = new MyClass();
            int num =  myclass.CountChar("fdfdfdfcxvcxcdfsdffvcdv", 'd');
            Console.WriteLine(num);
            Console.Read();
        }

    }
    class MyClass
    {
        public
         int CountChar(String str,char ch)
        {
            return str.Split(ch).Length - 1;
        }
    }

}

原文地址:https://www.cnblogs.com/zhchoutai/p/6958512.html