Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在Java中,有一些方法可以扫描类路径/所有类/包内并枚举其中的类。例如,spring 组件扫描使用类似这样的方法来扫描所有类并找到带有有趣注释的类。
如果有任何类似的 C# 技术,如果有,使用哪些 API?
反射 API是您通过 C# 执行此操作的方式。
您可以使用Assembly 类来查看程序集(即:包)。在程序集中,您可以使用Assembly.GetTypes检索所有类的列表。
上面的第一个链接演示了如何使用它的很多选项。