C#VS如何整个项目中查找字符串

2025-02-02 14:57:33
推荐回答(1个)
回答1:

List subIndex = new List();
string A = "ssddxx等级:12kkkcxc12kkk等级:31sxsd1xd等级:52kkkcsdfsdf2k等级:44";
int ii = A.IndexOf("等级");
while (ii >= 0 && ii < A.Length)
{
subIndex.Add(ii);
ii = A.IndexOf("等级", ii + 1);
}

int[] arrIndex = subIndex.ToArray(); //你要的数组