Refactoring C# Series: Use Automatic Property

Name Use Automatic Property Summary You have a property in a class which just wraps a field of the same type, and simply returns or sets that field. private string _field1; public string Field1 { get { return _field1; } set { _field1 = value; } } Becomes: public string Field1 { get; set; } C# Version 3.0 Motivation Encapsulation is quite possibly the key principle [...]

Lesen Sie den vollständigen Eintrag unter http://richardbushnell.net/index.php/2007/12/28/refactoring-c-sharp-series-use-automatic-property/

Published Donnerstag, 27. Dezember 2007 23:00 von .Net Smoothie