How would you count occurrences of a string within a string?
I am doing something where I realised I wanted to count how many /s I could find in a string, and then it struck me, that there were about several ways to do it, but couldn't decide on what the best (or easiest) was.
At the moment I'm going with something like:
string source = "/once/upon/a/time/";
int count = source.Length - source.Replace("/", "").Length;
But I don't like it at all, any takers?
I don't really want to dig out RegEx for th