Alias Varghese
Alias Varghese

Reputation: 2172

Shortcut to change property to full property

I already have a property like this

public int MyProperty{get; set;}

I need to change this property as a full property like this

private int myVar;

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

any shortcut available in VS2013 for this?

Upvotes: 1

Views: 1459

Answers (3)

Alias Varghese
Alias Varghese

Reputation: 2172

The answer I was looking for was Ctrl + r with Ctrl + E.

Upvotes: 0

JdB
JdB

Reputation: 11

Type "propfull" in the editor and press TAB twice, change the property type if desired. Press TAB again to change backing name and property name if desired.

Upvotes: 1

Gian Paolo
Gian Paolo

Reputation: 4249

In VS2015, Right click on myVar -> Quick Actions...-> Encapsulate field

Even better if you first rename it as m_myVar -> Visual studio will generate a property named MyVar

Don't have VS2013 right now, but should be the same, maybe no need for "Quick actions..."

Upvotes: 1

Related Questions