To test if object implements interface in C# - Pattern matching overview
Aug 17, 2021 · 1 min read · Is there anyway of testing if an object implements a given interface in C#? Solution: Solution 1: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 I...
Join discussion