code_junkie

How would one access object properties in CIL (MSIL)

Nov 13th, 2011
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. var s = "hello world";
  2. var i = s.Length;
  3.  
  4. .locals init ([0] string s,
  5. [1] int32 i)
  6. IL_0000: nop
  7. IL_0001: ldstr "hello world"
  8. IL_0006: stloc.0
  9. IL_0007: ldloc.0
  10. IL_0008: callvirt instance int32 [mscorlib]System.String::get_Length()
  11. IL_000d: stloc.1
  12.  
  13. static void Main(string[] args)
  14. {
  15. string h = "hello world";
  16. int i = h.Length;
  17. }
  18.  
  19. .method private hidebysig static void Main(string[] args) cil managed
  20. {
  21. .entrypoint
  22. .maxstack 1
  23. .locals init (
  24. [0] string h,
  25. [1] int32 i)
  26. L_0000: nop
  27. L_0001: ldstr "hello world"
  28. L_0006: stloc.0
  29. L_0007: ldloc.0
  30. L_0008: callvirt instance int32 [mscorlib]System.String::get_Length()
  31. L_000d: stloc.1
  32. L_000e: ret
  33. }
Add Comment
Please, Sign In to add comment