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
Post a Comment