CSharp examples for System:Type
Returns all types in that directly or indirectly implement or inherit from the given type.
using System.Reflection; using System.Linq; using System.Collections.Generic; using System;/*from w w w . ja v a 2 s . c o m*/ public class Main{ /// <summary> /// Returns all types in <paramref name="assembliesToSearch"/> that directly or indirectly implement or inherit from the given type. /// </summary> public static IEnumerable<Type> GetImplementors(this Type abstractType, params Assembly[] assembliesToSearch) { var typesInAssemblies = assembliesToSearch.SelectMany(assembly => assembly.GetTypes()); return typesInAssemblies.Where(abstractType.IsAssignableFrom); } }