Alex Rivera | Logout

Get only direct interface instead of all?

Asked 2011-03-15T22:07:31.913
24

I have a class like the below. GetInterfaces() says

If the current Type represents a type parameter in the definition of a generic type or generic method, this method searches the interface constraints and any interfaces inherited from class or interface constraints.

Is it possible for me to not get any inherited interface? When i use GetInterfaces on ABC i only want to see DEF, not DEF and GHI.

interface DEF : GHI {...}
class ABC : DEF {...}
Edit
Report

1 Answer

-1

The same MSDN page says

The GetInterfaces method does not return interfaces in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which interfaces are returned, because that order varies.

So no, you can't skip interfaces.

answered 2011-03-15T22:12:38.523

Your Answer