gpt4 book ai didi

c# - 获取一个类在 C# 中继承和实现的所有类型和接口(interface)

转载 作者:太空宇宙 更新时间:2023-11-03 17:24:26 25 4
gpt4 key购买 nike

我看到这个问题和我的很相似:

How to find all the types in an Assembly that Inherit from a Specific Type C#

但是,如果我的类也实现了多个接口(interface)怎么办:

class MyClass: MyBaseClass, IMyInterface1, IMyInterface2

我能否以某种方式获取 MyClass 实现的所有内容的数组,而不是一个一个地获取?

最佳答案

对于接口(interface)你可以调用Type.GetInterfaces()

关于c# - 获取一个类在 C# 中继承和实现的所有类型和接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28607604/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com