使用变量创建构造函数的快捷方式(C#Visual Studio 2010) [英] Shortcut for creating constructor with variables (C# Visual Studio 2010)
问题描述
在Visual Studio 2010 C#中,您可以在一个类中键入 ctor
,然后按 tab ,Visual Studio会为我为该类创建一个构造函数.非常方便.
In Visual Studio 2010 C# you can, in a class, type ctor
and then press tab and Visual Studio will create a constructor for that class for me. It is very convenient.
但是有没有办法让Visual Studio用我所有的变量,属性等创建一个构造函数?
But is there a way to make Visual Studio create a constructor with all my variables, properties and so on?
例如,
public class User
{
public String UserName { get; private set; }
}
为此,我希望 ctor
+ tab 使我成为
And for this I want ctor
+ tab to make me a
public User(string UserName)
{
this.UserName = UserName;
}
推荐答案
感谢Samuel Slade(告诉我这是代码段),我设法找到了另一个StackOverflow答案:
Thanks to Samuel Slade (telling me it's called code-snippets) I managed to find another Stack Overflow answer: Snippet code to create constructor in VS2010 Express
答案是否定的,并非没有插件/扩展程序.
And it seems as the answer is NO, not without a plugin/extension.
许多参考 ReSharper 扩展名.
这篇关于使用变量创建构造函数的快捷方式(C#Visual Studio 2010)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!