How to set a default value using "short style" properties in VS2008 (Automatic Properties)?

.net, c#, properties, visual-studio-2008

Solution

Just set the "default" value within your constructor.

public class Person
{
   public Person()
   {
       this.FirstName = string.Empty;
   }

   public string FirstName { get; set; }
}

Also, they're called Automatic Properties.

Problem

How can I setup a default value to a property defined as follow: ``` public int MyProperty { get; set; } ``` That is using "prop" [tab][tab] in VS2008 (code snippet). Is it possible without falling back in the "old way"?: ``` private int myProperty = 0; // default value public int MyProperty { get { return myProperty; } set { myProperty = value; } } ``` Thanks for your time. Best regards.

Original source