I Want to see how many time's a string occurrs in a string. For example I want to see how many times 2018 occurs in this paragraph:
zaeazeaze2018
azeazeazeazeaze2018azezaaze
azeaze4azeaze2018
In this case it is occuring 3 times.
I tried the following code
But the problem is that it always returns 0
And I can't find the mistake here:
public static string count(string k)
{
int i = 0;
foreach(var line in k)
{
if (line.ToString().Contains("Bestellung sehen"))
{
i++;
i = +i;
}
}
return i.ToString();
}