Hello everyone,
There are two ways to use reflection to invoke a method,
1. Using InvokeMember;
2. Using GetType.GetMethod to retrieve a MethodInfo object, then use the MethodInfo object to invoke the method.
My point is from the result point of view, they are the same, but method 2 if more efficient if we want to invoke the method multiple of times by the same MethodInfo object -- since each time we call InvokeMember, it needs to find the method, nothing saved as MethodInfo object in method 2 and each time InvokeMember did the binding to find the same method.
My question is whether my point of understanding is correct and whether there any more differences/pros/cons compared with the 2 methods.
thanks in advance,
George
George GeorgePosted Sep 9, 2008, 2:07 AM
My question is not asking which one is faster, but why faster? Any comments? :-)
regards,
George
Bechir BejaouiPosted Sep 8, 2008, 1:48 PM
create a class and within it impelment the two method 1 and 2 then foreach method do impelement a counter this counts the execution duration to make the measure