The error is pretty self explanatory:
Operator '==' cannot be applied to operands of type 'string' and 'string[]'
It's tell you that this line:
if (searchTerm == blogPost)
is trying to compare two very different types - in this case a
string
with an array of strings
string[]
That's pretty understandable if you think about it: can you compare a coin with a stack of mixed coins in the real world?
No - you would compare your coin with each element of the stack one by one!
You need to do the same thing with your code, and as Gerry has said, that means indexing the array so you compare each string one by one.
There are other problems though: once found, you continue to search which is pointless as identical blogs will give you repeated results, or you will waste time processing the rest of the strings unnecessarily.
The way I'd do it is different:
string searchTerm = Console.ReadLine();
string result = "The blogpost doesn't exist";
foreach (string blog in blogPost)
{
if (searchTerm == blog)
{
result = $"\tThe post is in the blog: {post[i]}";
break;
}
}
Console.WriteLine(result);
break;
As foreach makes code more readable if you aren't interested in the index value.
Though in fact, I'd use simpler code and Linq methods:
string result = blogPost.FirstOrDefault(b => b == searchTerm);
Console.WriteLine(result == null ? "The blogpost doesn't exist"
: $"\tThe post is in the blog: {result}");