What is the simplest way of testing if an object implements a given interface in C#? (Answer to this question in Java)
If you want to use the typecasted object after the check: Since C# 7.0:
if (obj is IMyInterface myObj)
This is the same as
IMyInterface myObj = obj as IMyInterface; if (myObj != null)
See .NET Docs: Pattern matching with is # Type pattern