Using Visual Studio shortcuts to create C# properties

In Visual Studio typing out new C# properties along with their get/sets can be tedious. A shortcut is to type..

‘prop’ and TAB TWICE to give you basic get/set…

public int MyProperty { get; set; }


‘propg’ and TAB TWICE to give you private set…

public int MyProperty { get; private set; }


‘propfull’ and TAB TWICE to give you full property with backing field…

private int myVar;

public int MyProperty
    get { return myVar; }
    set { myVar = value; }

The example below shows the simple ‘prop’ usage.

Get/Set Visual Studio shortcut

Visual Studio inserts the type of the new property as int but after insertion it¬†will select ‘int’ so if you don’t want int you can just start typing your desired type immediately.

If you do want int you can press tab to move over to the property name and again just start typing… you don’t need to set the cursor with the mouse.

Leave a Reply

Your email address will not be published. Required fields are marked *