G
Gomaw Beoyr
If I have an object o and want to check if it's a certain interface,
I write like this:
bool oIsIMyInterface = o is IMyInterface;
However, if I have a Type object t, and I want to check if it's a
certain interface, I have to write the interface name as a string:
bool tIsIMyInterface = t.GetInterface("MyNamespace.IMyInterface") != null;
Is there any way to do this without putting the interface between
quotes, i.e. without writing it as a string, i.e. getting it
type-checked etc by the compiler?
Something along these lines:
bool tIsIMyInterface = t.IsSubclassOf(typeof(IMyInterface)) != null;
Regards,
/Gomaw
I write like this:
bool oIsIMyInterface = o is IMyInterface;
However, if I have a Type object t, and I want to check if it's a
certain interface, I have to write the interface name as a string:
bool tIsIMyInterface = t.GetInterface("MyNamespace.IMyInterface") != null;
Is there any way to do this without putting the interface between
quotes, i.e. without writing it as a string, i.e. getting it
type-checked etc by the compiler?
Something along these lines:
bool tIsIMyInterface = t.IsSubclassOf(typeof(IMyInterface)) != null;
Regards,
/Gomaw