Given a string and substring and we have to check whether a substring contains in a string or not using C#.Net.
string.Contains()
string.Contains() method returns true if given substring is exists in the string or not else it will return false.
Syntax:
bool string.Contains(string substring);
Consider the program:
Output
For first case: We are checking string (substring) "How" in the string str, the condition will be true because string str contains "How" but in other (second) case we are cheking "Who" which is not exists in string str i.e. string str does not contain the substring “Who”. Thus, condition will be false.