-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
Implemented Needs ECMA SpecThis feature has been implemented in C#, but still needs to be merged into the ECMA specificationThis feature has been implemented in C#, but still needs to be merged into the ECMA specificationProposalProposal champion
Milestone
Description
- Speclet: https://github.com/dotnet/csharplang/blob/main/proposals/csharp-14.0/null-conditional-assignment.md
- Discussion: Null-conditional assignment #8676
Summary
Permits assignment to occur conditionally within a a?.b or a?[b] expression.
using System;
class C
{
public object obj;
}
void M(C? c)
{
c?.obj = new object();
}using System;
class C
{
public event Action E;
}
void M(C? c)
{
c?.E += () => { Console.WriteLine("handled event E"); };
}void M(object[]? arr)
{
arr?[42] = new object();
}Design meetings
- https://github.com/dotnet/csharplang/blob/main/meetings/2022/LDM-2022-04-27.md#null-conditional-assignment
- https://github.com/dotnet/csharplang/blob/main/meetings/2022/LDM-2022-08-31.md#null-conditional-assignment
- https://github.com/dotnet/csharplang/blob/main/meetings/2022/LDM-2022-10-26.md#null-conditional-assignment
- https://github.com/dotnet/csharplang/blob/main/meetings/2024/LDM-2024-10-28.md#increment-and-decrement-operators-in-null-conditional-access
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Implemented Needs ECMA SpecThis feature has been implemented in C#, but still needs to be merged into the ECMA specificationThis feature has been implemented in C#, but still needs to be merged into the ECMA specificationProposalProposal champion