如何使用反射获取在基类中声明的方法? [英] How to get methods declared in Base class using Reflection?

查看:62
本文介绍了如何使用反射获取在基类中声明的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Windwos 8存储应用程序中使用反射调用方法。我试图使用this.GetType()。GetTypeInfo()。DeclaredMethods从基类方法获取所有方法的列表。

I am trying to invoke methods using Reflection in Windwos 8 store application. I tried to get list of all methods from a base class method using this.GetType().GetTypeInfo().DeclaredMethods.

var methodList = base.GetType().GetTypeInfo().DeclaredMethods;

我能够获取在子类中声明的所有
方法并调用它们。但是我无法获得在基类中定义的方法的列表。

方法有什么问题?
此项目是使用.Net for Windows存储构建的。

I am able to get all methods declared in the child class and invoke them. But i am unable to get list of methods defined in the base class.
what is wrong with the approach? this project built using .Net for Windows store

推荐答案

GetType().GetRuntimeMethods()

此方法给出了我想要的。
在运行时获取了对象内部存在的所有方法。

This method gave what i wanted. Got all the methods present inside the object during runtime.

这篇关于如何使用反射获取在基类中声明的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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