C# Equivalent of InStr

In VB there is a test using InStr as to whether a string contains another string. C# uses a different function for the equivalent test.

An example of the VB InStr function is given below

If InStr(DishName,"apple") > 0 Then
  Return True
End If
  Return False
}

In the above example the name of the dish is checked to see if it contains the word apple.

c# uses the IndexOf function to perform a comparable operation.

The equivalent of the test from the example above is

if (DishName.indexOf("apple")  != -1) {
  return true;
}
  return false;
}