string msg = "你怎么又咳嗽了啊? 怎么能不咳嗽呢? 感冒了啊 多喝水就不会咳嗽了啊 是的 好的啊!";
int count = 0;
int index = 0;
{
count++;
Console.WriteLine("第{0}", index);
index = index + keywords.Length;
}
Console.ReadKey();
int count = 0;
int index = 0;
string keywords = "咳嗽";
while ((index=msg.IndexOf(keywords,index))!=-1){
count++;
Console.WriteLine("第{0}", index);
index = index + keywords.Length;
}
Console.ReadKey();