I had the next problem: I had a type T (in a template) and I wanted to check if it implemented a certain interface. I finally managed it the next way:
if (typeof(<InterfaceName>).IsAssignableFrom(typeof(T)))
{
// .. some code
}
I found another way to archive the same thing. The method mentioned above doesn't work in all situations. typeof(<object>).GetInterfaces("<interfacename>") != null seems to work also
Een reactie posten
1 opmerking:
I found another way to archive the same thing. The method mentioned above doesn't work in all situations.
typeof(<object>).GetInterfaces("<interfacename>") != null seems to work also
Een reactie posten