Conditional / Ternary Operator
Conditional Operator / Ternary Operator :
- condition ? true_expression : false_expression;
- bool x = condition ? true : false;
string result = (percentage >= 36) ? "pass" : "fail" ;
--------------------------------------------------------
NullCoalesce (??)
- int totalMarks = marks ?? 0 ;
int? x = null; int y = x ?? -1;
int? is a shorthand for Nullable, which itself is shorthand of Nullable. eg Nullable a = null; A nullable type can represent the correct range of values for its underlying value type, plus a additional null value.--------------------------------------------------------
Comments