简体   繁体   English

使用基础创建构造函数的快捷方式(C#Visual Studio 2015)

[英]Shortcut for creating constructor with base (C# Visual Studio 2015)

In Visual Studio C# you can, in a class, type ctor and then press Tab and Visual Studio will create a constructor for that class for me. 在Visual Studio C#中,您可以在一个类中键入ctor ,然后按Tab键 ,Visual Studio将为我为该类创建一个构造函数。 Very convenient. 很方便。

But is there a way (shortcut) to make Visual Studio generate all constructors with bases from its inherited class? 但是,是否有一种方法(快捷方式)可以使Visual Studio从其继承的类生成具有基数的所有构造函数?

For example, 例如,

public class User:ClassA
{
    public User() {}
    public User(string S):base(S) {}
    public User(string S, int I):base(S, I) {}
    ...
}

I do not have ReSharper and it is possible. 我没有ReSharper,这是可能的。

You can select your base class and press Shift + Alt + F10 and select Generate All : 您可以选择您的基类,然后按Shift + Alt + F10并选择Generate All

在此处输入图片说明

I am not sure if it comes with the Visual Studio 2015 installation; 我不确定它是否随Visual Studio 2015安装一起提供。 maybe you need to add an extension. 也许您需要添加扩展名。 I am not sure which one of them it is required. 我不确定是否需要其中之一。

Following the extensions I have installed that maybe good candidates: 按照我安装的扩展程序,可能是不错的选择:

  • Application Insights Tools for Visual Studio 适用于Visual Studio的Application Insights工具
  • PowerShell Tools for Visual Studio 2015 适用于Visual Studio 2015的PowerShell工具
  • Productivity Power Tools 2015 生产力电动工具2015
  • Snippet Designer 片段设计师
  • Visual Studio Extensibility Templates Visual Studio扩展模板

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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