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

喜夏-厌秋 提交于 2019-12-11 05:38:22

问题


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. Very convenient.

But is there a way (shortcut) to make Visual Studio generate all constructors with bases from its inherited class?

For example,

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

回答1:


I do not have ReSharper and it is possible.

You can select your base class and press Shift + Alt + F10 and select Generate All:

I am not sure if it comes with the Visual Studio 2015 installation; 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
  • PowerShell Tools for Visual Studio 2015
  • Productivity Power Tools 2015
  • Snippet Designer
  • Visual Studio Extensibility Templates


来源:https://stackoverflow.com/questions/36385408/shortcut-for-creating-constructor-with-base-c-visual-studio-2015

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!