
86Microsoft Visual Studio 2010: A Beginner’s Guide
Listing 3-10 Auto-implemented properties
C#:
public string FirstName { get; set; }
VB:
Public Property FirstName As String
Figure 3-4 The C# property snippet template
The automatic property, FirstName, is logically equivalent to the expanded FirstName with accessors and backing field. Behind the scenes, the compiler produces the expanded version where the backing field is guaranteed to have a unique name to avoid conflicts.
Do not overlook that when you use automatic properties, you cannot add your own code that runs inside the get or set accessors.
The Property Snippet
To create a property snippet, type pro and press TAB, TAB; and you’ll see the property snippet template shown in Figure
A C# property snippet template creates an automatic property by default, but the VB snippet template is a normal property with full get and set accessors.