首页 > 其他 > 详细

8_6学习内容演练。

时间:2015-08-07 08:13:27      阅读:215      评论:0      收藏:0      [点我收藏+]
 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();

  

 

8_6学习内容演练。

原文:http://www.cnblogs.com/suncan0/p/4709683.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!