Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   any possibility of calling a method by it's String name? (http://www.go4expert.com/forums/possibility-calling-method-string-t1105/)

most_afar 1Aug2006 16:58

any possibility of calling a method by it's String name?
 
Hi
Is it possible to call a method by it's String name?
something like this:

System.callByName("MyMethod1","MyParameters");

where the mothod "MyMethod1" is defined somewhere accessible with
parameters "MyParameters".

Thank you.

shabbir 1Aug2006 17:19

Re: any possibility of calling a method by it's String name?
 
You need to use System.Reflection class to extract detail of a class. The MemberInfo class available in System.Reflection namespace is an abstract class. It discovers the attributes of a member and provides access to the member metadata. You need to assign the details you need to query about a type viz. Constructors/Methods/Interfaces/Fields/Property etc. to the MemberInfo class local variable and use methods like GetFields/GetMethods/GetInterfaces etc ...

most_afar 3Aug2006 16:44

Re: any possibility of calling a method by it's String name?
 
Thank you shabbir.
your comment was usefull for me.

shabbir 3Aug2006 18:05

Re: any possibility of calling a method by it's String name?
 
My pleasure.


All times are GMT +5.5. The time now is 11:39.