C# If Else Shorthand with Examples – Programming, Pseudocode Example, C# Programming Example
C# Console If Else Statement

C# If Else Shorthand with Examples

C# Question Mark Operator

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.

 

For more examples : C# Question Mark Operator & Examples

 

Example 1: The greatest number amoung two numbers 

 

Example 2:(Alternative solution)

 

Leave a Comment

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