In what cases should public fields be used instead of properties? [duplicate]
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: Public Data members vs Getters, Setters In what cases should public fields be used, instead of properties or getter and setter methods (where there is no support for properties)? Where exactly is their use recommended, and why, or, if it is not, why are they still allowed as a language feature? After all, they break the Object-Oriented principle of encapsulation where getters and setters are allowed and