Day 1: C# 15 Collection Expressions Just Got Superpowers – with()

sukhpinder08041 pts0 comments

Day 1: C# 15 Collection Expressions Just Got Superpowers — with(…) | .Net ProgrammingSitemapOpen in appSign up<br>Sign in

Medium Logo

Get app<br>Write

Search

Sign up<br>Sign in

Mastodon

.Net Programming

Explore the .Net with the latest in C# from basic to advanced, including .Net versions 9, 8, 6, 5, Core 3.1, .Net Framework, ASP.NET Core, MVC, design patterns, OOPS, and SOLID principles. Get top tutorials, best practices, and hands-on code examples on GitHub.

Member-only story

Featured

Day 1: C# 15 Collection Expressions Just Got Superpowers — with(…)

Meet the new with(…) syntax that lets you pass capacity, comparers, and more directly inside the brackets.

Sukhpinder Singh

3 min read·<br>Just now

Listen

Share

Press enter or click to view image in full size

This image was created using an AI image creation programHey everyone 👋<br>If you’ve been coding in C# for a while, you know that little flutter of joy when a new language feature feels like it was built just for you.<br>Well… grab your coffee, because C# 15 just dropped the mic on collection expressions.<br>Remember when we got [1, 2, 3] in C# 12 and we all lost our minds? Yeah. That was cute.<br>This? This is superpowers.<br>The problem we all pretended wasn’t annoying<br>You wanted a list that wouldn’t resize itself 47 times?<br>var names = new List(initialCapacity); // ugh, two lines<br>names.AddRange(someValues);Or a case-insensitive HashSet without the constructor dance?<br>You ended up with either ugly code… or you just accepted the tiny performance hit and moved on.<br>Not anymore.<br>Enter: with(…) — the first element that changes everything

Published in .Net Programming<br>5.6K followers<br>·Last published just now

Explore the .Net with the latest in C# from basic to advanced, including .Net versions 9, 8, 6, 5, Core 3.1, .Net Framework, ASP.NET Core, MVC, design patterns, OOPS, and SOLID principles. Get top tutorials, best practices, and hands-on code examples on GitHub.

Written by Sukhpinder Singh

3.1K followers<br>·41 following

C# .Net developer 👨‍💻 who's 100% convinced my bugs are funnier than yours. 🐛💥 #BugLife Pubs: https://medium.com/c-sharp-programming

Help

Status

About

Careers

Press

Blog

Store

Privacy

Rules

Terms

Text to speech

collection expressions superpowers core sign programming

Related Articles