Like in Eclipse for Java, where it can auto-generate getters and setters for class variables, can Visual Studio 2010 do this as well?
Asked
Active
Viewed 2.9k times
4 Answers
27
I usually type prop
in the code editor and then press Tab twice. Another possibility is to right click on the private field and Refactor -> Encapsulate Field ...
or Ctrl+R,E but the first method is more convenient for me.

Darin Dimitrov
- 1,023,142
- 271
- 3,287
- 2,928
-
wow that is cool i never knew that. it doesn't generate everything completely, but its a lot better template than i was working with. – Scott Oct 10 '10 at 15:17
-
Beat me to it. I don't have VS installed on this machine to double check ;) – ChrisF Oct 10 '10 at 15:19
-
But still, is there anything to just generate all public properties for each variable in the class similar to eclipse? or is this the only way... – Scott Oct 10 '10 at 15:22
-
@Scott, I am not aware of any. – Darin Dimitrov Oct 10 '10 at 15:24
2
Press 'Alt + Insert', then choose 'Properties'. Though I tried it in VS 2012, not sure about 2010 but still worth a try.
There all of your class variables are visible. Select the variables that you want to create properties of. This is similar to what you have referred to in Eclipse.

Syed Waqas
- 2,576
- 4
- 29
- 36
0
you aso have to option to download an addin who does that ie : http://www.codeproject.com/KB/codegen/PropertiesGenerator.aspx

VANDERWEYEN Jonathan
- 660
- 1
- 5
- 12