in cil code, ldftn is used to get the address of the function pointer to invoke the delegate constructor (i.e. .ctor (object, native int)).How to get the function pointer used to create a delegate in C #?
Your question is formulated in such a way that it is difficult to understand what you are actually trying to do. I think maybe something like this:
MethodInfo mi = ... var ptr = mi.MethodHandle.GetFunctionPointer(); // now call a delegate .ctor using that ptr
If you are looking for what Reflection.Emit code should look like, then something like this:
il.Emit(OpCodes.Ldftn, yourMethodInfo); il.Emit(OpCodes.Newobj, yourDelegateType.GetConstructors()[0]);
. "" . yourDelegateType - typeof(Func<string>) ..
yourDelegateType
typeof(Func<string>)