Yes.. Thank you Lee thats what i did last.
But its preferable that if we can identify propertie using MemberType.
Why did they miss this checking ? then whats the need of a MemberType enum
object
in the MethodInfo class where Type.GetMethods(....) always returns methods
only
no property or constructor etc ( i mean its not possible to differentiate
them)..
Thanks
Jibesh.V.P
"Lee Alexander" <lee@NoSpamPlease_Digita.com> wrote in message
news:uG**************@TK2MSFTNGP02.phx.gbl...
Following code gets all the Properties inside the class too and there is
no way to
differentiate a method from property.
That's because properties are implemented using methods. So in your
example for property 'Data' you will see methods:
Int32 get_Data()
Void set_Data(Int32)
You have two choices as I see it if you want to differentiate between
methods that aren't being used for properties. The first is to look for
get_ and set_ patterns in the methods and hide them or alternatively iterate
over the properties first for a class getting their associated get and set
method infos and then remove them from your methods list.
I prefer the last approach as this guarantees what you want.
HTH
Regards
Lee
"jibesh.vp" <ji*******@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl... Hi all,
I have a doubt in using C# Reflection mechanism .
What i need is to get method info alone from a class type.
Following code gets all the Properties inside the class too and there is
no way to
differentiate a method from property.
MemberType propertie of the MethodInfo class always have the value "
Method " for all the methods and properites
Any Help
sample:
public class MyTypeClass
{
public void MyMethods() { }
private int data;
public int Data
{
get{ return this.data; }
set { this.data = value; }
}
}
public class TypeMain
{
public static void Main()
{
Type myType =(typeof(MyTypeClass));
MethodInfo[] myArrayMethodInfo =
myType.GetMethods(BindingFlags.Public|BindingFlags .Instance|BindingFlags.Dec
laredOnly);
- Jibesh.V.P