Why not just post the article from the C# docs instead? The pvs blog seems to add little to no additional information.
- Union types
I know this is something folks have been clamoring for for a long time. It looks to me, though, like you're still dealing with object casts, under the hood, so not sure how useful this will be.
- Closed hierarchies
Neat. Niche, but neat. I could see myself using this.
- Labeled break and continue
Boy, this one feels like it should have existed a decade ago. I will ABSOLUTELY be using this.
- Extension indexers
I.E. we can now polyfill Range support. Cool.
- Collection expression arguments
I am absolutely mindboggled by anyone who thinks this syntax is a good idea. Seriously, it's EXACTLY as verbose as the thing it's trying to replace. What problem does this solve?
- Memory safety
Sounds neat, I guess. Doubt I'll ever use it.
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
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"
};
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.
Dunno if struct unions made it, but if they did - there should be a way to avoid boxing with object.
If they didn't make it - yeah, the feature is fucking useless 😅
.NET
Getting started
Useful resources
IDEs and code editors
- Visual Studio (Windows/Mac)
- Rider (Windows/Mac/Linux)
- Visual Studio Code (Windows/Mac/Linux)
Tools
Rules
- Rule 1: Follow Lemmy rules
- Rule 2: Be excellent to each other, no hostility towards users for any reason
- Rule 3: No spam of tools/companies/advertisements
- Rule 4: Submit the original source. If a post reports on something found on another site, submit the latter
Related communities
Wikipedia pages
- .NET (open source & cross platform)
- .NET Framework (proprietary & Windows-only)