方法一:
string test = "FF FF FF FF 01 00 82 00 00 A2 00 00 FB 07 FF FF FF FF 01 00 82 00 00 A2 00 00 FB 07"; string r = test.Replace("FF FF FF FF",""); int num = (test.Length - r.Length) /11; //(11是'FF FF FF FF'的长度) Response.Write(num);
方法二:
string aaa = "aabaabbaabb"; int a= aaa.Split(new string[] { "aa" }, StringSplitOptions.None).Length-1;