简体   繁体   中英

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

I'm using the class designer in Visual Studio 2008 and when I add properties to my classes 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

您还可以使用snippet propfull ,然后使用Tab和Tab创建属性。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM