0

What is the difference between initializing an object in these two ways:

MyObject myObject = new MyObject()
{
    Id = 1,
    Color = green
}

VS.

MyObject myObject = new MyObject
{
    Id = 1,
    Color = green
}
user3689167
  • 863
  • 1
  • 14
  • 28

2 Answers2

0

There is no difference, they compile to the same code.

Scott Chamberlain
  • 124,994
  • 33
  • 282
  • 431
-1

There's no difference - the parentheses in the first example are optional. Hope that helps.