Difference in instantiating a variable using parentencis and not
with parentheses
var myCity = new CityDto()
{
Id = 1,
Name = "NY"
};
Without parentheses
var myCity = new CityDto
{
Id = 1,
Name = "NY"
};
Difference in instantiating a variable using parentencis and not
with parentheses
var myCity = new CityDto()
{
Id = 1,
Name = "NY"
};
Without parentheses
var myCity = new CityDto
{
Id = 1,
Name = "NY"
};
There's no difference. When calling the default constructor, but using the object initializer syntax, the ()
can be removed.
If you were to remove the object initializer, the ()
are required.