From 0f42c1eb20b6e3bc8ba4a69436500e7f15ee43fd Mon Sep 17 00:00:00 2001 From: James Montemagno Date: Thu, 5 Feb 2026 11:08:21 -0800 Subject: [PATCH 1/3] Update csharp.md for Preview 1 --- release-notes/11.0/preview/preview1/csharp.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/release-notes/11.0/preview/preview1/csharp.md b/release-notes/11.0/preview/preview1/csharp.md index 32d54dcfc4..84ea22c55d 100644 --- a/release-notes/11.0/preview/preview1/csharp.md +++ b/release-notes/11.0/preview/preview1/csharp.md @@ -2,7 +2,13 @@ .NET 11 Preview 1 includes the following C# features & enhancements. -This Preview 1 release does not introduce new C# feature additions. +Here's a summary of what's new in C# in this Preview 1 release: + +- [Feature](#feature) + +## Feature + +Feature summary. C# updates: From 867c18badf6e9f79e8f1c73cfbb0ef8800685404 Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Thu, 5 Feb 2026 16:55:57 -0500 Subject: [PATCH 2/3] first draft for C# --- release-notes/11.0/preview/preview1/csharp.md | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/release-notes/11.0/preview/preview1/csharp.md b/release-notes/11.0/preview/preview1/csharp.md index 84ea22c55d..146b840a69 100644 --- a/release-notes/11.0/preview/preview1/csharp.md +++ b/release-notes/11.0/preview/preview1/csharp.md @@ -1,14 +1,27 @@ # C# in .NET 11 Preview 1 - Release Notes -.NET 11 Preview 1 includes the following C# features & enhancements. +.NET 11 Preview 1 includes two new features in C#: -Here's a summary of what's new in C# in this Preview 1 release: +- [Collection expression arguments](#collection-expression-arguments) +- [Extended layout support](#extended-layout-support) -- [Feature](#feature) +## Collection expression arguments -## Feature +This feature enables developers to pass arguments to the constructor of a collection using [collection expression](https://learn.microsoft.com/dotnet/csharp/language-reference/operators/collection-expressions) syntax. You use the `with()` contextual keyword for the first element in the collection expression: -Feature summary. +```csharp +// Initialize to twice the capacity since we'll have to add +// more values later. +List names = [with(capacity: values.Count * 2), .. values]; +``` + +The compiler generates code to call the []`List` constructor](https://learn.microsoft.com/dotnet/api/system.collections.generic.list-1.-ctor#system-collections-generic-list-1-ctor(system-int32)) with the `capacity` argument set to `values.Count * 2`. + +You can learn more about this new feature in the [What's new in C# 15](https://learn.microsoft.com/dotnet/csharp/whats-new/csharp-15) article. You'll find a longer description, and links to other documentation on the feature. + +## Extended layout support + +The C# compiler emits the `TypeAttributes.ExtendedLayout` for types that have the `System.Runtime.InteropServices.ExtendedLayoutAttribute` applied. This is primarily intended for the .NET runtime team to use for types in interop scenarios. C# updates: From afb31fa071a01116be14fe71470682e56265018f Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Fri, 6 Feb 2026 10:34:55 -0500 Subject: [PATCH 3/3] 2nd draft of release notes --- release-notes/11.0/preview/preview1/csharp.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/release-notes/11.0/preview/preview1/csharp.md b/release-notes/11.0/preview/preview1/csharp.md index 146b840a69..a5e5600726 100644 --- a/release-notes/11.0/preview/preview1/csharp.md +++ b/release-notes/11.0/preview/preview1/csharp.md @@ -7,7 +7,9 @@ ## Collection expression arguments -This feature enables developers to pass arguments to the constructor of a collection using [collection expression](https://learn.microsoft.com/dotnet/csharp/language-reference/operators/collection-expressions) syntax. You use the `with()` contextual keyword for the first element in the collection expression: +This feature supports scenarios where a collection expression doesn't produce the collection type you need. You might want to pre-allocate storage because you know how you'll use the collection. For sorted collections, you may want to specify a different expression to compare items in the collection. For dictionaries, you may need a different expression to compare or find keys. + +You specify arguments to the constructor of the collection in a `with()` element in the [collection expression](https://learn.microsoft.com/dotnet/csharp/language-reference/operators/collection-expressions). The `with()` element must be the first element in the collection exprssion. You can specify values for any of the arguments to a specified constructor for the collection, as shown in the following example: ```csharp // Initialize to twice the capacity since we'll have to add @@ -15,9 +17,11 @@ This feature enables developers to pass arguments to the constructor of a collec List names = [with(capacity: values.Count * 2), .. values]; ``` -The compiler generates code to call the []`List` constructor](https://learn.microsoft.com/dotnet/api/system.collections.generic.list-1.-ctor#system-collections-generic-list-1-ctor(system-int32)) with the `capacity` argument set to `values.Count * 2`. +The compiler generates code to call the [`List` constructor](https://learn.microsoft.com/dotnet/api/system.collections.generic.list-1.-ctor#system-collections-generic-list-1-ctor(system-int32)) with the `capacity` argument set to `values.Count * 2`. + +You can learn more about this new feature in the [What's new in C# 15](https://learn.microsoft.com/dotnet/csharp/whats-new/csharp-15) article. You'll find a longer description, and links to other documentation on the feature. This information includes information on how to specify arguments when the target type is an interface, such as `IEnumerable`. -You can learn more about this new feature in the [What's new in C# 15](https://learn.microsoft.com/dotnet/csharp/whats-new/csharp-15) article. You'll find a longer description, and links to other documentation on the feature. +This feature will integrate with [dictionary expressions](https://github.com/dotnet/roslyn/blob/main/docs/Language%20Feature%20Status.md#working-set-c), which is in progress now. ## Extended layout support