Mixed object and collection initializers
Summary
Relax the existing restriction that a { ... } initializer following new T(...) must contain only member initializers or only element initializers. A single initializer would be allowed to contain any sequence of the two kinds, interleaved freely. Each element keeps its existing per-kind meaning — member_initializers assign to the named field/property/event (or invoke the indexer), and element_initializers invoke an Add method on the object being initialized.
var div = new HtmlDivElement
{
Width = "100%",
Height = "100%",
new HtmlSpanElement { Style = { FontColor = "red" }, "Span 1" },
new HtmlSpanElement { Style = { FontColor = "blue" }, "Span 2" },
};
Mixed object and collection initializers
Summary
Relax the existing restriction that a
{ ... }initializer followingnew T(...)must contain only member initializers or only element initializers. A single initializer would be allowed to contain any sequence of the two kinds, interleaved freely. Each element keeps its existing per-kind meaning — member_initializers assign to the named field/property/event (or invoke the indexer), and element_initializers invoke anAddmethod on the object being initialized.