标签:
检索一个字符串:
Console.Write("请输入一个字符串:"); string strA = Console.ReadLine(); Console.Write("请输入要查找的字符串:"); string strB = Console.ReadLine(); strA = strA.ToLower(); strB = strB.ToLower(); // if (strA.Contains(strB)) //{ int n = 0; //int i=1 //while (i != -1) int i; do { i = strA.IndexOf(strB);//找不到返回-1 strA = strA.Substring(i + 1); n++; } while (i != -1); Console.Write("查找的字符串的个数为" + (n - 1).ToString()); // } //else //{ // Console.Write("没有"); // } Console.ReadLine();
标签:
原文地址:http://www.cnblogs.com/liuyudong0825/p/4707895.html