================================================== =====
?? is a C# binary operator used to provide a default value should the left operand be null. For example:
Expand|Select|Wrap|Line Numbers
- X = A ?? B;
Expand|Select|Wrap|Line Numbers
- if(A != null)
- X = A;
- else
- X = B;
Expand|Select|Wrap|Line Numbers
- string result = ( TextBox1 ?? new TextBox() ).Text;
================================================== =====
?: is a C# (and many other languages) ternary operator used to return a value based on the evaluation of a boolean expression. This one is far more commonly known than the ?? operator, because it has its roots in C, but I'm still surprised at how many people don't know how to use it. Here's an example of how it works:
Expand|Select|Wrap|Line Numbers
- X = A ? B : C;
Expand|Select|Wrap|Line Numbers
- if(A)
- X = B;
- else
- X = C;
Expand|Select|Wrap|Line Numbers
- string substr = fullstr.Length > 10 ? fullstr.Substring(0, 10) : fullstr;
================================================== =====
Hope you found this enlightening!