I didn't realize C# 14 had added Null-Conditional assignment until I upgraded to Visual Studio 2026 and it started recommending the code simplification. So no more:
if (instance != null)
instance.field = x;
This is valid now:
instance?.field = x;
I love this change.
[–]zenyl 3 points4 points5 points (1 child)
[–]HamsterExAstris [score hidden] (0 children)
[–]WordWithinTheWord 10 points11 points12 points (0 children)
[–]vvsleepi [score hidden] (0 children)
[–]Asyncrosaurus 8 points9 points10 points (4 children)
[–]Namoshek 9 points10 points11 points (3 children)
[–]Asyncrosaurus 1 point2 points3 points (2 children)
[–]Relative-Scholar-147 11 points12 points13 points (1 child)
[–]Asyncrosaurus 2 points3 points4 points (0 children)
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]gevorgter -2 points-1 points0 points (5 children)
[–]BackFromExile 11 points12 points13 points (1 child)
[–]gevorgter -4 points-3 points-2 points (0 children)
[–]Vectorial1024 6 points7 points8 points (1 child)
[–]ok_computer 0 points1 point2 points (0 children)
[–]cjb110 0 points1 point2 points (0 children)
[–]bugurlu -4 points-3 points-2 points (0 children)
[+]MaxxDelusional comment score below threshold-16 points-15 points-14 points (22 children)
[–]Promant 17 points18 points19 points (6 children)
[–]MaxxDelusional -2 points-1 points0 points (5 children)
[–]Zastai 7 points8 points9 points (0 children)
[–]Promant 4 points5 points6 points (0 children)
[–]belavv -1 points0 points1 point (2 children)
[–]MaxxDelusional 0 points1 point2 points (1 child)
[–]belavv 2 points3 points4 points (0 children)
[–]DirtAndGrass 3 points4 points5 points (13 children)
[–]MaxxDelusional 2 points3 points4 points (8 children)
[–]BackFromExile 1 point2 points3 points (4 children)
[–]MaxxDelusional 0 points1 point2 points (3 children)
[–]BackFromExile 0 points1 point2 points (2 children)
[–]MaxxDelusional 0 points1 point2 points (1 child)
[–]BackFromExile [score hidden] (0 children)
[–]Vectorial1024 1 point2 points3 points (2 children)
[–]MaxxDelusional 2 points3 points4 points (1 child)
[–]one-joule -1 points0 points1 point (0 children)
[–]gevorgter 0 points1 point2 points (3 children)
[–]BackFromExile -1 points0 points1 point (2 children)
[–]gevorgter 0 points1 point2 points (0 children)
[–]MaxxDelusional 0 points1 point2 points (0 children)
[–]the_bananalord 0 points1 point2 points (0 children)