Dev Tools · 2h ago
C# 15 Pre-Allocation: Speed Gains from New Syntax
A developer benchmarked three ways to create a list of 100,000 integers in C# 15. The new `with(capacity:)` syntax combined with collection expressions showed measurable speed improvements over uninitialized lists. Pre-allocating capacity cut runtime significantly compared to the naive approach.
Meridian48 take
The performance gains are real but incremental; the bigger story is C# 15's continued push toward expressive, allocation-aware code patterns.
csharp-15performance-optimization