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

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;
        }
    }

}

posted @ 2017-06-07 18:22  zhchoutai  阅读(140)  评论(0编辑  收藏  举报