开发者

How do I create auto-implemented properties in the VS class designer

开发者 https://www.devze.com 2023-03-31 13:34 出处:网络
I\'m using the class designer in Visual Studio 2008 and when I add properties to my clas开发者_开发技巧ses they are created with an empty setter and a getter that throws a NotImplementedException. In

I'm using the class designer in Visual Studio 2008 and when I add properties to my clas开发者_开发技巧ses they are created with an empty setter and a getter that throws a NotImplementedException. In the properties window there's an option called "Auto-Implemented" which is always greye out. Is there a way to change the settings for this so by default new properties will be auto-implemented or some way to turn this option on so I don't have to keep editing the code each time I add in a new property?


AFAIK, you can't. I asked this at Barcelona a year or so ago - I don't think anything has changed. Basically, as I understand it, this is done directly (not via an editable snippet).


For visual studio 2008 you could install this "power toys" that give you another option to class designer menu "create auto-implemented property"

http://modeling.codeplex.com/

i'll waiting this for Visual Studio 2010 too... else it's so annoying


You can create field, and encapsulate it(Refactor->Encapsulate field).
This can help for simple properties.


You can also create a property by using snippet propfull, then Tab, Tab.

0

精彩评论

暂无评论...
验证码 换一张
取 消