Home > Article > Backend Development > C# equivalent of Java's double bracket initialization?
Double bracket initialization in Java does the same job as single bracket initialization in C#.
Double brackets create and initialize objects in a single Java expression.
Let us say the following is in Java -
List<String> list = new List<String>() {{ add("One"); add("Two"); add("Three"); add("Four"); }}
is the same as the collection initializer in C# -
List<String> list = new List<String>() {"One","Two", “Three”, “Four”};
The above is the detailed content of C# equivalent of Java's double bracket initialization?. For more information, please follow other related articles on the PHP Chinese website!