Place an object on top of stack in ILGenerator

Posted by KiNGPiN on Stack Overflow See other posts from Stack Overflow or by KiNGPiN
Published on 2011-02-14T07:15:31Z Indexed on 2011/02/14 7:25 UTC
Read the original article Hit count: 279

Filed under:
|
|
|

I have to pass a function an instance of an object, so obviously all the information to be taken as argument is to be loaded onto the evaluation stack Here is the code that i am looking for

someClass SomeObject = new someClass();

il.Emit(OpCodes.LoadObject, SomeObject);
il.Emit(OpCodes.CallVirt, MethodInfo Function);


public void Function(Object obj)
{
       Type type = typeof(obj);
       //do something w.r.t to the type
}

I dont require any information stored in the class just the type and i cannot use any of the primitive types to take my decision on

Last i read that i can use a pointer to load the type using some opcodes ... but i am completely lost here, any help or pointers to the right direction would be great :)

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET