Object initializers
suggest changeSyntax
- SomeClass sc = new SomeClass { Property1 = value1, Property2 = value2, … };
- SomeClass sc = new SomeClass(param1, param2, …) { Property1 = value1, Property2 = value2, … }
Remarks
The constructor parentheses can only be omitted if the type being instantiated has a default (parameterless) constructor available.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents