C# – Conditional Ternary / Comparision and Logical Operator

As usual today as well I will be showing operators in C#

Shortcut for evaluating  an expression  and returning a result;

Conditional Ternary Operator

result = ( a == b) ? "Equal" : "Not Equal";

Here we are saying that if a and b is equal, evaluate first expression which is “Equal”, if not then evaluate “Not Equal”

Comparision and Logical Operator

Comparision operators used for conditional statements.

For example ;

== (equal)

!= (not equal)

(greater than=

(greater than or equal)

!someBoolenValue (means NOT is true)

Logical Operators

used to combine multiple operations / evaluate

&& (and)

|| (or)

combine with paranthesis () for order of presence

 

Leave a comment

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