如何在C#中使用Type API区分类和委托[重复]

问题描述 投票:0回答:2

Type.IsClass属性表明类型是类还是委托。如何使用Type.IsClass类API区分这些(类和委托)?

c# class reflection delegates
2个回答
1
投票

您可以检查是否键入Type Type

is a subclass of

0
投票

如果创建了上述代表的实例,则可以使用System.Delegate运算符进行检查

typeof(Foo).IsSubclassOf(typeof(System.Delegate)));
© www.soinside.com 2019 - 2024. All rights reserved.