代码演示:
源代码:
public ArrayList GetArrayList()
{
ArrayList arrayList = new ArrayList();
string a = "ssd级cdx等级?:12kk级?kcx级c12k等级c!:3级c1sx级csd1级cxd等级:2k等级:44";
string b = "级c";
int pos = a.IndexOf(b);
while (pos > -1)
{
arrayList.Add(pos);
pos += b.Length;
if (pos >= a.Length) break;
pos = a.IndexOf(b, pos);
}
return arrayList;
}
static void Main(string[] args)
{
Program a = new Program();
foreach(int i in a.GetArrayList())
{
Console.WriteLine(i);
}
Console.ReadLine();
}
代码效果: