How to generate getters and setters in Visual Stud

2019-01-16 00:27发布

By "generate", I mean auto-generation of the code necessary for a particuliar selected (set of) variable(s).

But any more explicit explication or comment on good practice is welcome.

15条回答
闹够了就滚
2楼-- · 2019-01-16 01:09

If you're using ReSharper, go into the ReSharper menu --> Code --> Generate ... (or hit Alt+Ins inside the surrounding class) and you'll get all the options for generating getters and/or setters you can think of :-)

查看更多
家丑人穷心不美
3楼-- · 2019-01-16 01:10

you can also use "propfull" and hit TAB twice, variable and property with get and set will be generate.

查看更多
Animai°情兽
4楼-- · 2019-01-16 01:10

In Visual Studio Community Edition 2015 you can select all the fields you want and then press ctrl + .to automatically generate the properties. You have to choose if you want to use the property instead the field or not.

查看更多
三岁会撩人
5楼-- · 2019-01-16 01:10

enter image description herebehalf of the visual studio tool we can easily generate c# properties using online tool called. c# propery generator.

查看更多
孤傲高冷的网名
6楼-- · 2019-01-16 01:19

Rather than using ctrl+k,x you can also just type prop and then hit tab twice

查看更多
迷人小祖宗
7楼-- · 2019-01-16 01:20

First get Extension just press (ctrl+shift+X) and install getter setter .... After this just select your variable and right click go to Command palette... And type getter ... It will suggest generate get and set methods click on this...

查看更多
登录 后发表回答