namespace FindWordInString
static void Main(string[] args)
string sentence = "Hello, my name is Janvi.";
int startIndex = sentence.IndexOf(word);
bool isWholeWord = (startIndex == 0 || !char.IsLetter(sentence[startIndex - 1])) &&
(startIndex + word.Length == sentence.Length || !char.IsLetter(sentence[startIndex + word.Length]));
Console.WriteLine("The word '{0}' was found in the sentence.", word);
Console.WriteLine("The word '{0}' was not found as a whole word in the sentence.", word);
Console.WriteLine("The word '{0}' was not found in the sentence.", word);