Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 
avatar of wablab

wablab

wablab has asked 0 questions and find answers to 2 problems.

Stats

96
EtPoint
39
Vote count
0
questions
2
answers

About

Code chameleon.

Vote for the C# "??=" operator!
https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/5921365-add-a-operator-to-c

Usage:

string message = null;
message ??= "Hello, world!"; // sets 'message' to "Hello, world!" since 'message' was null...
message ??= "Goodbye, world!";  // leaves 'message' set to "Hello, world!" since 'message' was not null...

The example above uses strings, but the operator would apply to any reference/nullable type. Currently, the best alternative to this would be:

message = message ?? "Hello, world!";