Console.Write("请输入字符串");

            string strA = Console.ReadLine();

            Console.Write("请输入要查找的字符");

            string strB = Console.ReadLine();


            int m = 0 , n = 0;

            bool isContains = strA.Contains(strB);

            if (isContains)

                

                for (int i = 0; i < strA.Length; i++)
                {
                    m = strA.IndexOf(strB, i);
                    if (m == i)
                    {
                        Console.WriteLine("出现的索引位置为" + m);
                        n++;
                    }
                }
            

            Console.WriteLine("出现的次数为" + n);
          

            Console.ReadLine();

  

 

相关文章:

  • 2021-04-02
  • 2022-01-14
  • 2021-06-22
  • 2022-12-23
  • 2022-03-10
  • 2022-02-24
猜你喜欢
  • 2022-12-23
  • 2021-11-24
  • 2021-05-04
  • 2022-01-01
  • 2021-12-03
  • 2021-10-17
相关资源
相似解决方案