Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to remove line break in C# Visual Studio if-statements

When I type

if (something) { *press Enter*

Visual Studio automatically moves the { to the next line. I tried to disable it via config but found anything but this option.

I basically want so that this

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

if (true)
{
   int m = 3;
}

turns into this

if (true) {
   int m = 3;
}

How to do it?

>Solution :

You can change the open brace to appear on the same line by unselecting the option "Place open brace on new line for types" in Visual Studio.

Tools > Options dialog box > Text Editor > C# > Code Style > Formatting

enter image description here

Reference : https://learn.microsoft.com/en-us/visualstudio/ide/reference/options-text-editor-csharp-formatting?view=vs-2022

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading