如果需要在一个字符串中找出一个特定串所有出现的位置,可以采用下面代码: publicint[]GetSubStrCountInStr(Stringstr,Stringsubstr,intStartPos)...{intfoundPos=-1;intcount=0;List<int>foundItems=newList<int>();do...{foundPos=str.IndexOf(substr,StartPos);if(foundPos>-1)...{StartPos=foundPos+1;count++;foundItems.Add(foundPos);}}while(foundPos>-1&&StartPos<str.Length);return((int[])foundItems.ToArray());}