IL DynamicMethod question - Boxing
C#
1
Posts
1
Posters
0
Views
1
Watching
-
Hey all I have dynamic method that get a type passed in. how do I use that param to box the object. So...
DynamicMethod dynamnicGet = new DynamicMethod("DynamicGet", typeof(object), new Type[] { typeof(object), typeof(Type) }, typeof(object)); ILGenerator il = dynamnicGet.GetILGenerator(); il.Emit(OpCodes.Ldarg_0); // load the source object onto the stack il.Emit(OpCodes.Callvirt, methodInfo); // call the method il.Emit(OpCodes.Ldarg_1); // load the type onto the stack // Now I want to box it the return type to the param type // Can not use il.Emit(OpCodes.Box, ) because I do not have the type in c#, it is in the IL il.Emit(OpCodes.Ret); // return
Hope that makes sense. Any ideas anyone? Thanks, Luke