Reputation: 61606
The coding style that my employer uses states that the brace {
should go on the same line, not the next one. Example:
class bar {
private void foo() {
if (1) {
Console.WriteLine("great");
} else {
Console.WriteLine("also great");
}
}
}
Visual Studio's default is to place braces on their own line.
How can I get Visual Studio to respect this coding style?
Upvotes: 1
Views: 88
Reputation: 8625
In VS 2017 you can use the following Option; TextEditor -> C# -> Code Style -> Formating -> New Lines:
Upvotes: 3
Reputation: 6356
(I don't have 2017, but this is what I see in 2015, so it may be similar.)
Under Tools -> Options -> Text Editor -> C# -> Formatting -> New Lines, there are several options for "Place open brace on new line for <X>" (where X may be "types" or "methods", etc), as well as "Place <X> on new line", where X is "else" or "catch" or "members in anonymous types".
You can check and uncheck these boxes as required to match the style your company sets up.
Upvotes: 4
Reputation: 62260
I believe it is called K&R style. I use JetBrains ReSharper, but it is not free.
Upvotes: 3