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”};
Updated on 22-Jun-2020 12:49:01