Reputation: 27
I have tried this but it does not match the string in array.
Note. I don't want to use regex.
string pgraph = ("i love zaiby and zaiby is my best friend");
string word = ("zaiby");
string[] singleword = pgraph.Split();
bool findword = singleword.Equals(word);
if (findword == true)
{
Console.Write("keyword founded");
}
else
{
Console.Write("keyword not founded");
}
Upvotes: 2
Views: 64
Reputation: 14059
You are comparing an array of strings to a string.
Try the following line instead of singleword.Equals
line:
bool findword = singleword.Any(w => w.Equals(word));
Upvotes: 2