I could use the following linq expression to count the number of occurrences of a word as follows:
string test = "And And And";
int j = test.Split(' ').Count(x => x.Contains("And"));
However what if I was searching for "And And", Is there a way to use linq to count words without using split. Do any of these methods take longer the O(n)?
int j = test.Split(' ').Count(x => x == "And");?