c# - Difference in instantiating a variable using parenthesis and not -


this question has answer here:

difference in instantiating variable using parentencis , 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 default constructor, using object initializer syntax, () can removed.

if remove object initializer, () required.


Comments

Popular posts from this blog

php - Autoloader issue not returning Class -

python - matplotlib equivalent for Ubuntu servers with no GUI? -

java - How to put two numbers separated by a space into two different arrays -