The IndexOf method can be used to find whether a string exists in another string.
string str1 = “welcome”;
string str2 = “come”;
int pos = str1.IndexOf(str2)
if pos is not equal to -1 then the search string str2 exists in the given string str1. Else the string does not exist.
Note: The string.Contains method can also be used to find the instring but it is not supported in dotnet framework version1 whereas IndexOf is supported in version1 and version2 as well.