Clayla John
0
Q:

null coalescing operator c#

//the null coalescing operator for c# is ??
int? x = null;
int y = 9;
return x ?? y; 
//Will return the value of x if x is not null else return y
7
//Return stirng representation of nullable DateTime
DateTime? x = null;
return x.HasValue == true ? x.Value.ToString() : "No Date";
1
is this condition true ? yes : no
1
// C# 8 null coalescing assignment operator:
a ??= b;
// the same as:
a = a ?? b;
0
int? length = people?.Length; // null if people is null
0

New to Communities?

Join the community