作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
由于这些 IL 代码我看到的更多,我喜欢学习如何正确解释它们。
我找不到像 C# Compiler 或任何其他文档这样的文档,所以我想在我学习了这些常见的之后,我几乎可以处理其余的事情:
以下是一些示例 IL 代码,其中包含我需要了解的内容:
示例 1:
.method private hidebysig static void Main(string[] args) cil managed
{
.entrypoint
// Code size 15 (0xf)
.maxstack 1
.locals init ([0] class EnumReflection.DerivedClass derivedClass)
IL_0000: nop
IL_0001: newobj instance void EnumReflection.DerivedClass::.ctor()
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: callvirt instance void EnumReflection.DerivedClass::WriteOutput()
IL_000d: nop
IL_000e: ret
} // end of method Program::Main
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 38 (0x26)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldstr "Hello"
IL_0006: stfld string EnumReflection.DerivedClass::hello
IL_000b: ldarg.0
IL_000c: ldstr "World"
IL_0011: stfld string EnumReflection.DerivedClass::world
IL_0016: ldarg.0
IL_0017: ldc.i4.s 123
IL_0019: stfld int32 EnumReflection.DerivedClass::age
IL_001e: ldarg.0
IL_001f: call instance void EnumReflection.BaseClass::.ctor()
IL_0024: nop
IL_0025: ret
} // end of method DerivedClass::.ctor
最佳答案
Microsoft standardized the CLR and published those standards . Part III包含了丰富的IL/CIL信息,适合学习。这是一份优秀的文件。
您还可以通过示例学习 IL。在 C# 中编译一些简单的方法并查看反射器中的 IL(它有一个 IL 模式)。
关于.net - 如何在 CLR 上学习 IL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10260272/
我是一名优秀的程序员,十分优秀!