Wednesday
Mar192008
.NET 3.5 Language Enhancements - Automatic Property Getters and Setters
Eric Phan |
Wednesday 19 March 2008 at 09:31 AM Nice little time saver here, to declare a trivial property (just sets and returns a private variable) all you need to do in .NET 3.5 is:
public string FirstName { get; set; }
This syntax looks exactly like how you would declare an interface or abstract property. Previously you would have to write code like this:
private string _firstName;
public string FirstName
{
get { return _firstName; }
set { _firstName = value; }
}
tagged
.NET,
C# in
Development
.NET,
C# in
Development 
Reader Comments