Search code examples
c#.netautomatic-propertiesspecifications

Is the implementation of Auto Properties in the spec?


Can I rely on the fact that the underlying field to a property named Foo is called "k__BackingField" ?


Solution

  • No, in short.

    And for this very reason, auto-properties are pain when used with field-based serializers like BinaryFormatter (I'm sure I might have mentioned that here before ;-p).

    See: Obfuscation, serialization and automatically implemented properties for some thoughts on this (and a solution).