如何在基本构造函数调用中禁用自动换行符 [英] How to disable automatic line break on base constructor call

查看:23
本文介绍了如何在基本构造函数调用中禁用自动换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的课程在 Visual Studio 中自动设置为这样的格式.

My classes are formatted like this automatically in Visual Studio.

[Serializable]
public class TestException : Exception {
    public TestException()
        : base() {
    }
}

我不希望在构造函数和基本构造函数调用之间发生换行,所以它应该是这样的.

I do not want that line break to happen between constructor and base constructor call, so it should look like this.

[Serializable]
public class TestException : Exception {
    public TestException() : base() {
    }
}

我需要更改哪些设置才能达到预期效果?

What settings would I have to change in order to achieve my expected result?

推荐答案

遗憾的是,Visual Studio 的内置 Options\Text Editor\C#\Formatting\New Lines 对话框中没有这样的设置.

Unfortunately there is no such setting in the Visual Studio's built-in Options\Text Editor\C#\Formatting\New Lines dialog.

如果您使用 ReSharper,在 Code Editing\C#\Formatting Style\Line Breaks and Wrapping 下有一个 Place constructor initializer on same line 选项:

If you use ReSharper there is a Place constructor initializer on same line option under Code Editing\C#\Formatting Style\Line Breaks and Wrapping:

这篇关于如何在基本构造函数调用中禁用自动换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆