C# 如何获取部件中的所有底部类型?

C# 如何获取部件中的所有底部类型?,c#,.net,reflection,C#,.net,Reflection,这是我的姐妹问题 如果我有一个 System.Reflection.Assembly 我有以下模型: class Person {} class Student : Person {} class Freshman : Student {} class Employee : Person {} class PersonList : ArrayList {} class StudentList : PersonList {} 如何枚举程序集的类型以获取对Employee、Freshman和St

这是我的姐妹问题

如果我有一个

System.Reflection.Assembly
我有以下模型:

class Person {}
class Student : Person {}
class Freshman : Student {}
class Employee : Person {}
class PersonList : ArrayList {}
class StudentList : PersonList {}
如何枚举程序集的类型以获取对Employee、Freshman和StudentList的引用

我希望能够枚举任何给定程序集的所有底部类型,如上面的示例


感谢您的时间:

所以您希望找到程序集中其他类型都无法派生的所有类型,对吗

为可读性而重构

var allTypes = assembly.GetTypes();
var baseTypes = allTypes.Select(type => type.BaseType);
var bottomTypes = allTypes.Except(baseTypes);
如果您想要.NET 2.0版本,请告诉我。那会有点痛