c# 中怎么判断字符个数

例如我要判断字符串"1234@2345@4567@7890"中有几个@应该怎么办呢

Regex testregex = new Regex("@");
String s = "1234@2345@4567@7890";
MatchCollection ms = testregex.Matches(s);
int count=ms.Count;

记得加上using System.Text.RegularExpressions;
温馨提示:答案为网友推荐,仅供参考
相似回答