How do I generate a constructor from class fields using Visual Studio (and/or ReSharper)?

前端 未结 12 1838
有刺的猬
有刺的猬 2020-11-27 12:54

I\'ve gotten accustomed to many of the Java IDEs (Eclipse, NetBeans, and IntelliJ IDEA) providing you with a command to generate a default constructor for a class based on t

12条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 13:51

    In Visual Studio 2015 Update3 I have this feature.

    Just by highlighting properties and then press Ctrl + . and then press Generate Constructor.

    For example, if you've highlighted two properties it will suggest you to create a constructor with two parameters and if you've selected three it will suggest one with three parameters and so on.

    It also works with Visual Studio 2017.

提交回复
热议问题