Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get MethodInfo for basic methods, not properties and events, via reflection? [duplicate]

I'm performing some reflective interrogation of an object. The code lists constructor(s), properties, and methods. GetMethods( ) returns property accessor/mutator methods and event add/remove methods.

How can I get just the basic method definitions?

Update

.IsSpecialName  

is the operative property. Thanks, @Hans.

like image 303
IAbstract Avatar asked Apr 26 '13 14:04

IAbstract


1 Answers

The following answer from this post Filtering out auto-generated methods getter/setter/add/remove/.etc) returned by Type.GetMethods() should work

typeof(MyType)
.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
.Where(m => !m.IsSpecialName)
like image 163
Darrin Doherty Avatar answered Oct 13 '22 15:10

Darrin Doherty