Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude "property methods" in Type.GetMethods?

I'm able to get the methods of a class using System.Type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly).

However, the returned list will include "property methods", e.g. get_PropertyX and set_PropertyX.

How can we ensure that the returned list exclude "property methods"?

like image 919
Pacerier Avatar asked Apr 21 '11 17:04

Pacerier


1 Answers

var methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
.Where(m => !m.IsSpecialName);
like image 198
StriplingWarrior Avatar answered Oct 10 '22 20:10

StriplingWarrior