Questions tagged by "string"


$1
 bounty
0
answers
How would you count occurrences of a string within a string?
5 years ago • kojemyakin
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 ...
Tags: ,
1 - 1 of 1 items