M
Mario Vargas
Hello all,
When using reflection, how can I find out if a particular type implements a
specific interface. For instance, I have the following code:
Type t = myAsm.GetType( "AssemblyToLoad.MyClass" );
Type iMyClassType = typeof(AssemblyToLoad.IMyClass);
foreach( Type i in t.GetInterfaces() )
{
Console.WriteLine( "Interface: {0}; Implemented: {1}, {2}",
i,
iMyClassType,
i.Equals( iMyClassType ) );
}
The type "AssemblyToLoad.MyClass" implements an interface called
"AssemblyToLoad.IMyClass", but the test "i.Equals( iMyClassType )" always
returns false. The code above is in a different assembly from the
"AssemblyToLoad" namespace.
Thanks for your help and tips...
Mario
When using reflection, how can I find out if a particular type implements a
specific interface. For instance, I have the following code:
Type t = myAsm.GetType( "AssemblyToLoad.MyClass" );
Type iMyClassType = typeof(AssemblyToLoad.IMyClass);
foreach( Type i in t.GetInterfaces() )
{
Console.WriteLine( "Interface: {0}; Implemented: {1}, {2}",
i,
iMyClassType,
i.Equals( iMyClassType ) );
}
The type "AssemblyToLoad.MyClass" implements an interface called
"AssemblyToLoad.IMyClass", but the test "i.Equals( iMyClassType )" always
returns false. The code above is in a different assembly from the
"AssemblyToLoad" namespace.
Thanks for your help and tips...
Mario