Connect with me
Search
Twitter Feed
Navigation
« LINQ to SQL with WCF - Lazy Loading and Caveats | Main | The Aggregate method in LINQ »
Wednesday
Mar192008

.NET 3.5 Language Enhancements - Automatic Property Getters and Setters

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; }
}

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>