Get a .NET type that declares an interface
Suppose the MyType implements the IMyInterface interface. How do I find the ad type of an interface? For example,
class UnitTest
{
MyTypeBase : IMyInterface { }
MyType : MyTypeBase { }
void Test() {
Type declaration = FindDeclaration(typeof(MyType), typeof(IMyInterface));
Assert.AreEqual(typeof(MyTypeBase), declaration)
}
+2
source to share
2 answers