Proposal: set only non-null values or do nothing #9044
-
Low level C#string oldValue = "value";
string? newNullValue = null;
if (newNullValue != null)
{
oldValue = newNullValue;
} Newest C# alternativeoldValue = newNullValue ?? oldValue; Proposal of new syntax (<<=)string oldValue = "value";
string? newNullValue = null;
string newValue = "new";
oldValue <<= newNullValue; // oldValue = "value"
oldValue <<= newValue; // oldValue = "new" I've found it handy in API development in cases, when client don't have to update all of entities fields with one update method. |
Beta Was this translation helpful? Give feedback.
Answered by
HaloFour
Jan 13, 2025
Replies: 1 comment 1 reply
-
See: #7560 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
DES-Destry
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See: #7560