Declaring a new instance of class with or without parentheses

Unless you wanted to initialize the property values, using the standard:

Person p = new Person();

Should suffice, but they are the same thing in your case and call the default constructor.

But, if you wanted to set the property values, you can do the following:

Person p = new Person { Name = "Harry", Age = 18 };

In this case there is no difference, they both call the default constructor. The difference would be obvious if there was another constructor with parameters:

var o = new Person { ... };
var p = new Person("John") { ... };

The empty parentheses are only needed when you don't use the initialization:

var p = new Person(); // Works
var o = new Person; // Error

Both will call the default parameter-less constructor. So I believe both are same.

Tags:

C#