反射,以获得代表信息 [英] Reflection to get the Delegate Information

查看:85
本文介绍了反射,以获得代表信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

执行以下我就可以得到有关方法

By executing the following i can get the information about methods

Type t=typeof(someType);

MemberInfo[] mInfo = t.GetMethods();



如何获取有关类型?

how to get information about delegates declared inside a type?

推荐答案

键入。 GetNestedTypes 得到嵌套类型和被委托(检查他们是否从的 System.MulticastDelegate ):

static IEnumerable<Type> GetNestedDelegates(Type type)
{
    return type.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic)
               .Where(t => t.BaseType == typeof(MulticastDelegate));
}

这篇关于反射,以获得代表信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆