Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. IL DynamicMethod question - Boxing

IL DynamicMethod question - Boxing

Scheduled Pinned Locked Moved C#
questioncsharpdotnetdata-structures
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Luke Murray
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups