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 - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -