C# Question Mark Operator & Examples – Programming, Pseudocode Example, C# Programming Example
C# Console Conditional Statement

C# Question Mark Operator & Examples

C# has a shortened version of an if else command. The use of it is very easy, if you understand it once

 

Notice:

The condition must evaluate to true or false. If condition is true, first_expression is evaluated and becomes the result. If condition is false, second_expression is evaluated and becomes the result. Only one of the two expressions is evaluated.

 

example 1:

if else syntax:

?: Operator

 

Example 2:

if else syx:

 

?: operator:

 

Example 3:

 

Example 4:

 

 

Leave a Comment

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