I'm trying to write something equivalent to the following in MSIL:
However, after I call the ReadKey() method and I have the ConsoleKeyInfo on the stack, I haven't found any way to get its address that doesn't involve using a local variable. Is it possible?Code:Console.ReadKey().KeyChar
Here's what I have:
Code:gen.Emit(OpCodes.Call, typeof(Console).GetMethod("ReadKey", Type.EmptyTypes)); gen.Emit(OpCodes.Stloc_0); gen.Emit(OpCodes.Ldloca, (ushort)0); gen.Emit(OpCodes.Call, typeof(ConsoleKeyInfo).GetProperty("KeyChar").GetGetMethod());


Reply With Quote