正则是个不错的选择,这个有个通俗的! int count = str.Replace("*", "").Replace("
用正则了var regex = new Regex("var matches = regex.Matches(str);Console.WriteLine(matches.Count);