Here’s a quick little snippet of how to check if one of your objects implements a specific interface. I’m not sure if there’s a ‘better’, or more efficient way to do this but I’ve been using this method to do this check for quite some time:
if (typeof(IMyInterface).IsAssignableFrom(myObject.GetType()))
{
//Do stuff...
}
UPDATE:
Turns out there is a way easier and probably much more efficient way of doing this! I just didn't know it worked with interfaces too
if (myObject is IMyInterface) { //Do Stuff.. }
Much nicer!