C# Equivalent to Java's Double Brace Initialization?

CsharpProgrammingServer Side Programming

Java’s Double Brace Initialization does the same work what a single brace can achieve in C#.

Double Brace creates and initialize objects in a single Java expression.

Let’s say the following is in Java −


List<String> list = new List<String>() {{

The same you can use for Collection Initializer in C# as −

List<String> list = new List<String>() {"One","Two", “Three”, “Four”};
Published on 31-Aug-2018 15:24:37