遇到一个小问题,我想多次检查某个字符是否在字符串中。这是字符串:
string str01 = "?????????? ??????????, ??????????, ???????? !!!";
现在我想检查字符 "?" 是否在字符串中出现至少 10 次。我尝试使用数组,但空格会欺骗它。提前致谢!
最佳答案
很有帮助,string
工具 IEnumerable<char>
, 所以你可以使用一些 LINQ:
var result = str01.Count(x => x == '?') > 10;
参见 this fiddle .
关于c# - 多次检查字符串中的字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38477476/