
public record Profile(string? Name);
public record User(Profile? Profile);
User? user = GetUser();
if (user != null && user.Profile != null)
user.Profile.Name = "John";
user?.Profile?.Name = "John";
user?.Profile.Name = "John";
user?.Profile.Name ??= "Guest";
user?.Profile.Name++;
(user?.Profile.Name, x) = ("Hi", 5);
Method(ref user?.Profile.Name);
Less Code, More Safety!
With C# 14's Null-Conditional assignment
🛡️
📜 Traditional way
🚀 C# 14's Null-Conditional Assignment
⚠️ LIMITATIONS
You can chain multiple ?. to check both user and Profile.
You can also chain it with null-coalescing
You can't use incrementation, destructuring and ref parameters.

static class StringExtensions
{
extension (string target)
{
void PrintInfo()
{
Console.WriteLine($"Length: {target.Length}");
Console.WriteLine($"Upper: {target.ToUpper()}");
Console.WriteLine($"Lower: {target.ToLower()}");
}
int WordCount =>
target.Split(' ').Length;
}
}
"Hello C# 14".PrintInfo();
Extension everything with C# 14!
Use target once for whole block, no more "this" parameter in each extension method
Now apart from methods you can extend types with additional properties!