C# Console Conditional Statement

C# Double Question Mark Operator with Example

Double question marks is a null coalescing operator.  The ?? operator is called the null-coalescing operator. It returns the left-hand operand if the operand is not null; otherwise it returns the right hand operand.(msdn)

there are 3 examples for c# double question mark example

In following code: The method above states result is assigned var1‘s value, unless var1 is null, in which case it is assigned var2‘s value. (overflowstack)

 

Example 1:

 

Example 2:

 

Example 3:

Old Solution

New Solution

 

Example 4:

 

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.