找到一段话中第二个关键字的位置

namespace  找到一段话中第二个关键字的位置

{
    class Program
    {
        static void Main(string[] args)
        {     //找第二个a
            string s = "cabcaceadf";
            int n = s.IndexOf("a");  //找到第一个a的索引n
            string x = s.Substring(n+1);  //从a的索引的位置以后开始截取,截取的数量为第一个a的索引后的所有数
            int m = x.IndexOf("a");   //重新找a的索引m
           Console.WriteLine(m);
           Console.ReadLine();
        }
    }
}

原文地址:https://www.cnblogs.com/lk-kk/p/4430492.html