Jas*_*ans 0 .net il ildasm .net-4.5
鉴于以下自动属性:
public string Name { get; set; }
我使用ILDASM分析它的IL,并对结果感到好奇:
.method public hidebysig specialname instance void
set_Name(string 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld string Strings.Person::'<Name>k__BackingField'
IL_0007: ret
} // end of method Person::set_Name
Run Code Online (Sandbox Code Playgroud)
我可以看到该方法接受一个名为的参数value,该参数对应于该调用ldarg.0.然而,ldarg.1由于我无法在方法签名中看到第二个参数,因此调用了我.
希望有人能解释一下这里发生了什么吗?