I can’t figure out what could be static here to cause that error below:
public bool OptionsMatch(Item item, ItemFavorite itemFavorite)
{
bool isSame = true;
switch (item.DispType)
{
case DispType.Dropdown:
case DispType.Radio:
isSame = String.Contains(item.Value);
break;
case DispType.ImageList:
isSame = ListValuesMatch(item, itemFavorite);
break;
}
return isSame;
}
Error: Cannot access non-static method ‘Contains’ in static context
DispType is an enum. And the rest are all non-static concrete type instances as well as the underlying class is not static either that contains this method.
string.Containsis not static, it is an instance method; i.e. it is called on an instance of a string, like so:This is because
Containsrequires two objects – the reference string, and the string to search for. You’ve only provided one (the string to search for) but not where to look.