<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/collection-expressions-with-arguments-in-c-15-vqxccqqha" -->

---
title: Collection expressions with arguments in C# 15 | daily.dev
description: C# 15 extends collection expressions, introduced in C# 12, with the ability to pass arguments to the underlying collection constructor or builder method using...
canonical: https://daily.dev/posts/collection-expressions-with-arguments-in-c-15-vqxccqqha
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Collection expressions with arguments in C# 15 | daily.dev
og:description: C# 15 extends collection expressions, introduced in C# 12, with the ability to pass arguments to the underlying collection constructor or builder method using...
og:url: https://daily.dev/posts/collection-expressions-with-arguments-in-c-15-vqxccqqha
og:image: https://api.daily.dev/og/posts/VQXcCQqha.png
og:image:alt: Collection expressions with arguments in C# 15
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Collection expressions with arguments in C# 15

**[Damir's Corner](https://daily.dev/sources/damirscorner)** · 4 min read · 10 upvotes · 0 comments

## Summary

C# 15 extends collection expressions, introduced in C# 12, with the ability to pass arguments to the underlying collection constructor or builder method using a new 'with(...)' syntax as the first element in the collection expression. This enables scenarios previously impossible with collection expression syntax, such as specifying an initial list capacity or passing a custom comparer to immutable collection builders like ImmutableHashSet.Create. The feature is still in preview as part of .NET 11 preview 7 and requires setting LangVersion to preview; it may change before the November release.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.damirscorner.com/blog/posts/20260904-CollectionExpressionsWithArgumentsInCs15.html>

## Questions this post answers

### How do I pass constructor arguments to a collection expression in C# 15?

Use the `with(...)` syntax as the first element inside the collection expression brackets, followed by the collection items. For example, `List<int> newSyntax = [with(10), 1, 2, 3];` creates a list with an initial capacity of 10, matching `new List<int>(10) { 1, 2, 3 }`. The `with` arguments must match a constructor of the collection type being initialized.

_daily.dev surfaces preview-feature writeups like this for developers tracking upcoming C# language changes._

### Can I use a custom comparer with ImmutableHashSet using collection expression syntax in C# 15?

Yes, collection expression arguments in C# 15 let you pass a comparer to builder methods like ImmutableHashSet.Create. Writing `ImmutableHashSet<string> newSyntax = [with(StringComparer.OrdinalIgnoreCase), "a", "A"];` is equivalent to calling `ImmutableHashSet.Create(StringComparer.OrdinalIgnoreCase, "a", "A")` directly, with arguments mapping to builder parameters before the items span.

_Developers weighing immutable collection syntax changes can follow C# language updates on daily.dev._

### Is the C# 15 collection expression arguments feature stable enough to use in production?

No, as of .NET 11 preview 7 the feature is still in preview and might change before the November release. To try it, set LangVersion to preview in the project file's PropertyGroup. Since it is only syntactic sugar over existing constructor and builder calls, its behavior is expected to remain functionally consistent even if exact syntax details shift.

_daily.dev helps developers stay ahead of preview-only C# features before committing code to them._

## Similar posts on daily.dev

- [Collection Expression Arguments Fix the Comparer Problem in C\# 15](https://daily.dev/posts/collection-expression-arguments-fix-the-comparer-problem-in-c-15-6qyslgktk) · Khalid Abuhakmeh · 1 upvotes · 0 comments
- [C\# 15 Collection Expression Arguments: What's New vs C\# 12 and 13](https://daily.dev/posts/c-15-collection-expression-arguments-what-s-new-vs-c-12-and-13-fbrmmg1kf) · We Are .NET · 9 upvotes · 1 comments
- [The best new features of C\# 14](https://daily.dev/posts/the-best-new-features-of-c-14-6gsbbjwv4) · InfoWorld · 46 upvotes · 4 comments
- [Indexer extension members in C\# 15](https://daily.dev/posts/indexer-extension-members-in-c-15-yabwnagyx) · Damir's Corner · 17 upvotes · 2 comments

---

Tags: [#.net](https://daily.dev/tags/.net), [#c#](https://daily.dev/tags/c#)

[View this post on daily.dev](https://daily.dev/posts/collection-expressions-with-arguments-in-c-15-vqxccqqha)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Collection expressions with arguments in C# 15","url":"https://daily.dev/posts/collection-expressions-with-arguments-in-c-15-vqxccqqha","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/collection-expressions-with-arguments-in-c-15-vqxccqqha"},"datePublished":"2026-09-04T06:47:52.844Z","dateModified":"2026-09-13T18:34:49.405Z","description":"C# 15 extends collection expressions, introduced in C# 12, with the ability to pass arguments to the underlying collection constructor or builder method using...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/425073b57495acf9675afac1769c56ee?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/425073b57495acf9675afac1769c56ee?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Damir's Corner","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Damir's Corner","logo":"https://media.daily.dev/image/upload/s--9Wkl5ofQ--/f_auto,q_auto/v1780213496/logos/damirscorner?_a=BAMAMiWQ0","url":"https://daily.dev/sources/damirscorner"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/collection-expressions-with-arguments-in-c-15-vqxccqqha","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":10},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":".net,c#","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Damir's Corner","item":"https://daily.dev/sources/damirscorner"},{"@type":"ListItem","position":3,"name":"Collection expressions with arguments in C# 15"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/collection-expressions-with-arguments-in-c-15-vqxccqqha#faq","mainEntity":[{"@type":"Question","name":"How do I pass constructor arguments to a collection expression in C# 15?","acceptedAnswer":{"@type":"Answer","text":"Use the `with(...)` syntax as the first element inside the collection expression brackets, followed by the collection items. For example, `List\u003cint\u003e newSyntax = [with(10), 1, 2, 3];` creates a list with an initial capacity of 10, matching `new List\u003cint\u003e(10) { 1, 2, 3 }`. The `with` arguments must match a constructor of the collection type being initialized. daily.dev surfaces preview-feature writeups like this for developers tracking upcoming C# language changes."}},{"@type":"Question","name":"Can I use a custom comparer with ImmutableHashSet using collection expression syntax in C# 15?","acceptedAnswer":{"@type":"Answer","text":"Yes, collection expression arguments in C# 15 let you pass a comparer to builder methods like ImmutableHashSet.Create. Writing `ImmutableHashSet\u003cstring\u003e newSyntax = [with(StringComparer.OrdinalIgnoreCase), \"a\", \"A\"];` is equivalent to calling `ImmutableHashSet.Create(StringComparer.OrdinalIgnoreCase, \"a\", \"A\")` directly, with arguments mapping to builder parameters before the items span. Developers weighing immutable collection syntax changes can follow C# language updates on daily.dev."}},{"@type":"Question","name":"Is the C# 15 collection expression arguments feature stable enough to use in production?","acceptedAnswer":{"@type":"Answer","text":"No, as of .NET 11 preview 7 the feature is still in preview and might change before the November release. To try it, set LangVersion to preview in the project file's PropertyGroup. Since it is only syntactic sugar over existing constructor and builder calls, its behavior is expected to remain functionally consistent even if exact syntax details shift. daily.dev helps developers stay ahead of preview-only C# features before committing code to them."}}]}
```

