print information about methods

  • Thread starter Thread starter Locia
  • Start date Start date
L

Locia

I would like print information about methods of FieldInfo class.
I don't want print information about property.How can do this?
Now with the following code also print information about property.

MethodInfo[] methods = typeof(FieldInfo).GetMethods();

foreach (MethodInfo m in methods)
{
Console.WriteLine(m);
}
 
Locia,

Do you mean you don't want the underlying methods that the properties
map to (get_property and set_property)? If that is the case, then you will
have to filter them out yourself, discarding method where the name begins
with set_ or get_ and the rest of the name is a valid property on the type.

Hope this helps.
 
Ollie,

That's not going to work. I tried looking for a combination of binding
flags that would filter out the methods that back the property accessors,
but with no luck. The OP will have to filter them out by the name.
 
I see your point Nick after a little demo program :) I guess filtering out
by name is the only way.

Ollie Riches





Nicholas Paldino said:
Ollie,

That's not going to work. I tried looking for a combination of binding
flags that would filter out the methods that back the property accessors,
but with no luck. The OP will have to filter them out by the name.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Ollie Riches said:
well you are going to have to use the overloaded method and specify the
BindingFlags

http://msdn.microsoft.com/library/d...html/frlrfsystemtypeclassgetmethodstopic2.asp

HTH

Ollie Riches
 
Back
Top