Indexoff
You can use the IndexOf method to get the index of a specific row. This method has an overload that takes a starting point where to look for it. When the specified string is not found, -1 returned.
Here is an example that should speak for itself.
var theString = "hello hello bye hello"; int index = -1; int helloCount = 0; while((index = theString.IndexOf("hello", index+1)) != -1) { helloCount++; } return helloCount==2;
Regex
Another way to get a counter is to use Regex:
return (Regex.Matches(hello, "hello").Count == 2);
pjvds source share