Get Sub Classes - CSharp System.Reflection

CSharp examples for System.Reflection:Assembly

Description

Get Sub Classes

Demo Code


using System.Reflection;
using System.Linq;
using System.Collections.Generic;
using System;/* w  w w . j a v a  2 s . com*/

public class Main{
        public static IEnumerable<Type> GetSubClasses<T>(params Assembly[] assemblies) => 
            assemblies
                .SelectMany(a => a.GetExportedTypes())
                .Where(type => type.IsSubclassOf(typeof(T)) && !type.IsAbstract);
}

Related Tutorials