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

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

arrays - Algorithm to find ideal starting spot in a circle -

php - Autoloader issue not returning Class -