What does a double question mark do in C#?

tom d picture tom d · Oct 22, 2009 · Viewed 65.4k times · Source

Possible Duplicates:
?? Null Coalescing Operator --> What does coalescing mean?
What do two question marks together mean in C#?

I couldn't find this question being asked here so I figured I would ask it. What does a double question mark do in C#?

Example:

x = y ?? z;

Answer

Alexis Abril picture Alexis Abril · Oct 22, 2009

This is a null coalescing operator. The method above states x is assigned y's value, unless y is null, in which case it is assigned z's value.