Reputation: 2710
I had looked up solutions here C# shortcut or shorthand getter setter but when I implement one of solutions
visual studio generates code like
private int myVar;
public int MyProperty
{
get { return myVar; }
set { myVar = value; }
}
what I want vs auto getter setter generator is to create getter setter for all of my variables and depending using their name like
private int id;
public int Id
{
get { return id; }
set { id= value; }
}
Is this possible?
Upvotes: 6
Views: 20445
Reputation: 1247
Type propfull tab tab
Then double-click on the variable "myVar" and replace it with what you want. VS will then replace the all other instances of it. You can also double-click on the type to change that and VS will change the auto code accordingly.
You can then edit the property name
Upvotes: 0
Reputation: 73442
Yes, Just create a field then Refactor->Encapuslate Field
. Shortcut is ctrl + R, E
Upvotes: 7