这里只要一行代码就行。
static void Main(string[] args)
{
string str = "qwerwqr;sfdsfds;fdfdsf;dfsdfsdf;dsfdsf;dsfdsf;";
int count = str.Length - str.Replace(";", "").Length;
Console.Write(count);
Console.ReadKey();
}
其中把要找的字符替换,然后再跟前字符串计算。就这么简单。
浙公网安备 33010602011771号