The "??" operator is called the null-coalescing operator and is used to define a default value for a nullable value types as well as reference types. It returns the left-hand operand if it is not null; otherwise it returns the right operand.
Example:
int? a = 123;
int? b = 5;
int? x = a ?? b;
/*Output:x = 123*/
int? a = null;
int? b = 5;
int? x = a ?? b;
/*Output:x = 5*/
No comments:
Post a Comment