get 'ldftn' function pointer in C#
Your question is phrased in a way that makes it hard to understand what you're actually trying to do. I think that perhaps what you want is something like this:
MethodInfo mi = ...
var ptr = mi.MethodHandle.GetFunctionPointer();
// now call a delegate .ctor using that ptr
If you're looking for how the Reflection.Emit code should look, then something like this:
il.Emit(OpCodes.Ldftn, yourMethodInfo);
il.Emit(OpCodes.Newobj, yourDelegateType.GetConstructors()[0]);
The first line loads the function pointer onto the stack. The second line "passes" it to the constructor of the delegate. yourDelegateType
should be something like typeof(Func<string>)
, etc.