关于IL的问题
目前正开始看有关IL的东西,感觉有点迷糊,我写了这样一个简单的类,如下
namespace consolepro
{
class Color
{
protected int red;
protected int green;
protected int blue;
public Color()
{
this.red = 0;
this.green = 127;
this.blue = 225;
}
public void GetRGB(ref int red,ref int green,ref int blue)
{
red = this.red;
green = this.green;
blue = this.blue;
}
}
}
然后进行build,得到.exe文件后察看GetRGB函数部分的IL代码,如下:
.method public hidebysig instance void GetRGB(int32& red,
int32& green,
int32& blue) cil managed
{
// Code size 26 (0x1a)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.1
IL_0002: ldarg.0
IL_0003: ldfld int32 consolepro.Color::red
IL_0008: stind.i4
IL_0009: ldarg.2
IL_000a: ldarg.0
IL_000b: ldfld int32 consolepro.Color::green
IL_0010: stind.i4
IL_0011: ldarg.3
IL_0012: ldarg.0
IL_0013: ldfld int32 consolepro.Color::blue
IL_0018: stind.i4