I'm looking for a way of detecting wheter or not a certain word is present in a string. For example, if I have the string "hi, this is me" I want to make sure "hi" is present; What I tried so far:
bool containsWord () {
string str = "hi, this is me";
return str.Contains ("hi");
}
Does not work properly: the problem with this is that I need to make sure the word itself is present and is not part of another word. With the code as it is, doing:
bool containsWord () {
string str = "this is me";
return str.Contains ("hi");
}
would still return true since "hi" is still a substring of "this". How can I avoid that?