The short answer . Yes, Child selects all the fields of the Base class, so it still has a dedicated support field. However, you cannot access it otherwise than through the Base.MyInt property.
Long answer :
Quick disassembly results.
Base and Child implementation of classes:
public class Base { public virtual int MyInt { get; set; } } public class Child : Base { private int anotherInt; public override int MyInt { get { return anotherInt; } set { anotherInt = value; } } }

As you can see, the support field exists in the Base class. . However, it is private, so you cannot access it from the Child class:
.field private int32 '<MyInt>k__BackingField'
And your Child.MyInt property Child.MyInt not use this field. Property IL:
.method public hidebysig specialname virtual instance int32 get_MyInt () cil managed { // Method begins at RVA 0x2109 // Code size 7 (0x7) .maxstack 8 IL_0000: ldarg.0 IL_0001: ldfld int32 ConsoleApplication2.Child::anotherInt IL_0006: ret } // end of method Child::get_MyInt .method public hidebysig specialname virtual instance void set_MyInt ( int32 'value' ) cil managed { // Method begins at RVA 0x2111 // Code size 8 (0x8) .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 IL_0002: stfld int32 ConsoleApplication2.Child::anotherInt IL_0007: ret } // end of method Child::set_MyInt
Uses the anotherInt field, as you might expect.
The only ways to access '<MyInt>k__BackingField' (indirectly, through the Base.MyInt property) are:
Base.MyInt from class Child
MarcinJuraszek Aug 12 '13 at 8:21 2013-08-12 08:21
source share