Given the following auto property:
public string Name { get; set; }
I analysed it's IL using ILDASM and was curious about the result:
.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
I can see that the method takes in a parameter named value
, which corresponds to the call ldarg.0
. However, the call to ldarg.1
caught me out as I cannot see a second parameter in the method signature.
Was hoping that someone could explain what's going on here please?
ldarg.0
loads the hidden this
parameter.ldarg.1
loads value
stfld
assigns the value on top of the stack to a field in the object below it on the stack.