14
you are viewing a single comment's thread
view the rest of the comments
[-] pipe01@programming.dev 3 points 1 week ago

Seriously, it's EXACTLY as verbose as the thing it's trying to replace. What problem does this solve?

How is it as verbose? It can replace multiple lines of Adds with a single bracketed expression

[-] JakenVeina@midwest.social 2 points 1 week ago

You mean like the "single bracketed expression" syntax we've had since... hell, I don't even know, C#4?

List<string> items =
[
    new(capacity: 10),
    "First",
    "Second",
    "Third"
];
var items = new List<string>(capacity: 10)
{
    "First",
    "Second",
    "Third"
};
[-] RaphaelSchmitz@feddit.org 3 points 1 week ago

I think it's las about verbosity and more about maintainability. I like to use collection expressions as direct arguments because they automatically get typed based on the parameter type. Something like

ProcessEmployees([ employee, manager ]);

Now if you adjust the parameter type from List<> to HashSet<> you don't need to change anything at the call site.

That was the situation before. With that new feature I can now configure the collection more where needed.

this post was submitted on 21 Oct 2026
14 points (100.0% liked)

.NET

1888 readers
1 users here now

Getting started

Useful resources

IDEs and code editors

Tools

Rules

Related communities

Wikipedia pages

founded 3 years ago
MODERATORS