I’m transitioning from C++ to C# and I have a method call that’s confusing me. I think I might be able to guess what it does, but I’d appreciate an expert just telling me straight:
WDResult returnValue = (WDResult)Invoke(
(MethodInfo)MethodBase.GetCurrentMethod(),
new object[] { request, loadType });
It looks to me like it’s using reflection to infoke the method that’s already being invoked. I can’t understand why one would do that if that is the case though. Also, why would you do it with reflection instead of just a recursion call? Note that in the code, a different overload is not being used in the call. The parameters request and loadType are pretty much passed straight into this code in the first line of the function it appears in.
That’s calling a custom
Invoke()method, which takes aMethodInfo.It isn’t standard reflection.
Look in the
Invoke()method to see why they’re doing that.