using System;
namespace 函数重载
{
  public class program
  {
    static void Main()
      {
        string msg = "你流口水弗兰克斯老师三发来看看老师是女方家老师那不就额老师编辑部艾达王老师出的" ;

        int count = 0;
        int index = 0;
        while((index = msg.IndexOf("老师",index)) != -1)
          {
            count++;
            Console.WriteLine("第{0}次出现“老师”的索引位置为:{1}", count, index);
            index += "老师".Length;
          }
          Console.WriteLine("一共出现了{0}次", count);
          Console.ReadKey();


      }


  }
}

posted on 2019-06-04 13:48  漂乎兮乎  阅读(162)  评论(0编辑  收藏  举报