C# 14 New Feature: Null-Conditional Assignment in .NET 10

Learn Microsoft AI demonstrates the new null-conditional assignment feature in C# 14 and .NET 10, showing how these updates can help you write safer, cleaner C# code.

C# 14 New Feature: Null-Conditional Assignment in .NET 10

Learn Microsoft AI presents a walkthrough of a C# 14 feature introduced in .NET 10: null-conditional assignment using ?. and ?[] as assignment targets. This update allows you to write expressions such as myObj?.Property = value; and myArray?[index] = value;, so the assignment only occurs if the target is not null.

What is Null-Conditional Assignment?

Example Usage

person?.Name = "Alex";
items?[3] = "New Value";

Advantages

When to Use

Learn More

Author: Learn Microsoft AI