3

Possible Duplicate:
How would you count occurences of a string within a string (C#)?

I am reading a file in line by line and need to count the number of tabs that each string contains. How can I get a count of the tabs i.e. \t from the string.

Thanks for your help

Community
  • 1
  • 1
Boardy
  • 35,417
  • 104
  • 256
  • 447

1 Answers1

9
uint howManyTabs(string s) {
    return (uint)s.Count(ch => ch == '\t');
}
Brennan Vincent
  • 10,736
  • 9
  • 32
  • 54