I am given the error
“The type or namespace name ‘passedType’ could not be found (are you missing a using directive or an assembly reference?)”
on the two references to passedType inside the function. Why does it not recognize the “passedType” variable?
public bool ObjectIsInHighlightedList(object thing, Type passedType)
{
foreach (object obj in _highlightedList)
{
if (obj is passedType && thing == (passedType)obj)
return true;
}
}
Try using the IsAssignableFrom method.
This would actually be a good scenario for a generic method, however: