Alex Rivera | Logout

Implementations of interface through Reflection

Asked 2008-09-17T05:20:42.723
40

How can I get all implementations of an interface through reflection in C#?

Edit
Report

1 Answer

4
Assembly assembly = Assembly.GetExecutingAssembly();
List<Type> types = assembly.GetTypes();
List<Type> childTypes = new List<Type>();
foreach (Type type in Types) {
  foreach (Type interfaceType in type.GetInterfaces()) {
       if (interfaceType.Equals(typeof([yourinterfacetype)) {
            childTypes.Add(type)
            break;
       }
  }
}

Maybe something like that....

answered 2008-09-17T05:49:54.040

Your Answer