Automatic properties would be nice short hand if you could initialize them. You cannot type the following:
public string Name { get; private set; } = "Fred"This means that strings and objects always default to null so you have to initialize them elsewhere. This defeats the point of the shorthand syntax.
I have seen the argument that these were added purely for Linq, but if this is the case why does the "prop" snippet produce automatic properties. This makes it even slower to produce a "fully blown" property definition, so things are actually worse than they were. Nice!
Go to Microsoft Connect to vote for the addition of initialization: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=361647
Edit 3/2/2009: The "shorthand syntax" to which you are referring does not exist for explicit properties either. For example, the following code is not valid:
public string Name { get { return name } private set { name = value; } } = "Fred"
string name;
The C# compiler will complain about the syntax used above. However, it is of course allowable to initialize an explicit backing field inline:
public string Name { get { return name } private set { name = value; } }
string name = "Fred";
An automatic property cannot be initialized inline like a field. This is a "limitation" of automatic properties that you must live with if you choose to use them, because they don't expose the backing field to user code (it is automatic). Alternatively, you can initialize an automatic property in a constructor to achieve the same result:
class Person
{
public string Name { get; private set; }
public Person()
{
Name = "Fred";
}
}