Using C# in VS2005, is there special way to create properties in the IDE or can you just type out the getters and setters?
views:
120answers:
4
+2
A:
Well, you can type the word prop
and then hit tab twice for a code snippet. propg
will generate a readonly property (only a getter).
Dan Tao
2010-05-06 12:42:59
+1 for knowing that it works in VS2005, just with the old-fashioned style backing field...
Pretzel
2010-05-06 12:59:05
Correct me if I'm wrong, but doesn't this create an automatic property which only has been added in C# 3.0 / Visual Studio *2008*? So I think this won't work for the OP then :( In case it shouldn't work it is possible to define one's own custom snippets as described here: http://aspalliance.com/863
0xA3
2010-05-06 12:53:30
@0xA3: No, it does work for VS2005 -- it creates a property the "old-fashioned" way (with a backing field plus a getter/setter).
Dan Tao
2010-05-06 12:55:16
+1
A:
I think what you're after are code snippets, have a look here and here.
There are also snippets besides prop
for properties that you may save you time, see here for the list of built-in snippets.
Nick Craver
2010-05-06 12:43:22
+1
A:
There are built-in code snippets - try typing prop
then pressing TAB
twice. This will automatically generate the code for a property with a getter a setter, and let you tab between a couple of points to declare property name and type.
Graham Clark
2010-05-06 12:43:55