C# 统计字符串出现的个数
string str1 = "123AAA456AAAA789AAAAAAA1011"; string str2 = "123456789AAA23456789AAAA3456789AAAAAAA4567890"; string str3 = "123456788AAA23456789AAAA3456789AAAAAAA4567890"; string str4 = "123456788AAA0AAAA0AAAAAAA"; var strArry = (str1 + "&" + str2 + "&" + str3 + "&" + str4).Split('&'); //把字符串连接为数组 char[] str1Arry = str1.ToArray(); int js = 0; List<int> TempArry = new List<int>(); for (int i = 0; i < str1Arry.Length; i++) { if (str1Arry[i] == 'A') { js++; continue; } if (js != 0) //找到A, 不等于A时候执行 { TempArry.Add(js); js = 0; //js归0 } }