I am counting the how many strings are present in the array-
Tags = "the cat the mat the sat";
string[] words = Tags.Split(' ');
int counter = 0;
foreach (string item in words)
{
if (item != "")
{
counter++;
}
}
However how could I modify my code so that I counted the occurrence of every string.
So for instance –
- “the” = 3
- “cat” = 1
- “mat” = 1
- “sat” = 1
and then store these values some way?
You don’t say what language you use, but what I see it looks like c#. Here is one way to do it.