Visual Studio 可以自动生成属性吗?

发布于 2024-09-27 04:40:46 字数 88 浏览 1 评论 0原文

就像在 Eclipse for Java 中一样,它可以自动生成类变量的 getter 和 setter,Visual Studio 2010 也能做到这一点吗?

Like in Eclipse for Java, where it can auto-generate getters and setters for class variables, can Visual Studio 2010 do this as well?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

白首有我共你 2024-10-04 04:40:46

我通常在代码编辑器中输入 prop,然后按 Tab 两次。另一种可能性是右键单击私有字段并Refactor -> Encapsulate Field ...Ctrl+R,E 但第一种方法对我来说更方便。

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.

高跟鞋的旋律 2024-10-04 04:40:46

只需编写 propfull + TAB 即可自动生成 getter &设置器的方式与 Eclipse 相同。

just write propfull + TAB to auto-generate getter & setters the way Eclipse would.

抽个烟儿 2024-10-04 04:40:46

按“Alt + Insert”,然后选择“属性”。虽然我在 VS 2012 中尝试过,但不确定 2010 年是否如此,但仍然值得一试。

您的所有类变量都是可见的。选择要为其创建属性的变量。这与您在 Eclipse 中提到的类似。

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.

沉溺在你眼里的海 2024-10-04 04:40:46

你也必须选择下载一个可以做到这一点的插件
即: http://www.codeproject.com/KB/codegen/PropertiesGenerator.aspx

you aso have to option to download an addin who does that
ie : http://www.codeproject.com/KB/codegen/PropertiesGenerator.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文