标签: c#
可能重复: How would you count occurences of a string within a string (C#)?
我正在逐行读取文件,需要计算每个字符串包含的标签数量。如何从字符串中获取选项卡的计数,即\ t。
感谢您的帮助
答案 0 :(得分:8)
uint howManyTabs(string s) { return (uint)s.Count(ch => ch == '\t'); }