Jaliya Udagedara 3/3/2026

C# 15: Collection Expression Arguments

Read Original

This technical article details the new C# 15 feature 'Collection Expression Arguments' available in .NET 11 Preview. It explains how to use the `with(...)` syntax within collection expressions to pass arguments (e.g., capacity for List<T>, comparers for HashSet<T>) to a collection's constructor, a limitation from C# 12. The post includes practical code examples demonstrating the syntax and its benefits for performance and code clarity.

C# 15: Collection Expression Arguments

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser