G
G
Grigory Shklyaruk2014-01-30 22:00:32
.NET
Grigory Shklyaruk, 2014-01-30 22:00:32

How to use reflection to get interfaces by base C# interface

There was a task in which it is necessary to receive all interfaces on the base interface. For classes, the following code works

var types = assembly.GetTypes().Where(item => item.BaseType == typeof(BaseEntity));

But for interfaces, this code does not work, it returns a null list to me

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Grigory Shklyaruk, 2014-01-31
@grifin85

Thanks to the post above, I got this code

var types = assembly.GetTypes().Where(item => item.GetInterfaces().Contains(typeof(IDependency)) && item.IsInterface);

D
Dmitry Guketlev, 2014-01-30
@Yavanosta

stackoverflow.com/questions/4963160/how-to-determin...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question