While trying to access the methodptr property of a delegate object, I am getting the error:
"System.Delegate._methodPtr' is not accessible in this context because it is 'Friend'
,is there some method through which I can access this value and assign it to a variable?
You can use reflection1 to retrieve the value. However, you probably don’t want to do this: this value is
Friendfor a reason. It’s an implementation detail and you as a consumer of the framework have no right to access it directly: it may work, or it may break suddenly (e.g. when Microsoft distributes an update of the library). Your code also won’t work on alternative .NET implementations, such as Mono.In particular, this member is not documented in the MSDN and as such its presence or behaviour can’t be relied on.
1 The following should do the trick:
Untested, since I only have Mono and (as mentioned above) it won’t work here anyway.