In .Net Framework 3.5 automatic properties were introduced. Automatic properties is a compiler feature that lets you write less code, and thereby increases your productivity. To add a property that only has a basic getter and setter, you only have to type:
The compiler then fills in the rest at compile time, making the above line equivalent to:
To create a read-only property, just make the setter private:
To simplify this even further, there are two code snippets, prop and propg, that generate template properties and let you fill in the name and type. The snippet "prop" generates a read/write property and "propg" generates a read-only property.
To invoke a snippet, start typing the snippet name and it will appear in the IntelliSense-window.
Pres tab once to auto-complete the snippet name, and tab again to expand the snippet name into the actual snippet.
Comments