0

How configure Visual Studio to format code like :

var obj = new Class1 {
    Property1 = 42,
    Property2 = "Some value",
    Property3 = new Class2 {
        Property1 = 7777,
        Property2 = "Other value"
    }
}

When Visual Studio auto format, it give :

var obj = new Class1
{
    Property1 = 42,
    Property2 = "Some value",
    Property3 = new Class2
    {
        Property1 = 7777,
        Property2 = "Other value"
    }
}

The curly bracket is put on a new line.

vernou
  • 6,818
  • 5
  • 30
  • 58

2 Answers2

2

You can try the search tool (Control + Q). By typing "braces" you get the option "New line options for braces", where you can set it.

enter image description here

tvdias
  • 821
  • 2
  • 10
  • 25
0

In Visual Studio C# code style, you need uncheck the option "Place open brace on new line for object..." : enter image description here

vernou
  • 6,818
  • 5
  • 30
  • 58