3 ms·
C# allows you to define getters and setters after the fact without breaking client code. foo.bar = x; // could be normal assignment or a setter.
by Gibbon1 6y ago
C# allows you to define getters and setters after the fact without breaking client code.
foo.bar = x; // could be normal assignment or a setter.
- thatjoeoverthr 6y agonot quite! a property is a pair of methods. if you replace a member with a property, it does remain code compatible as you describe, but breaks the ABI. so if you do this in a published library, clients require a recompile. for this reason, they recommend: 1) different naming convention between members and props 2) dont expose members; use properties from the start for anything public to assist with two, they introduce the default get/set implementation, like so: public object Derp { get; set; } for when you want to expose an interface with the assignment idiom but dont actually have any interesting implementation