·  C# – Syntax – Operators – Logical

 

- Info:

  - This tutorial shows how to use Conditional Operators in C#.: && || !.

  - They are used to create complex logical structures from individual Comparison Operations.

 

- Example:

  - Create C# Console Application Test.cs.

 

    Test.cs

    using System;

   

    class Test {

   

      static void Main(string[] args) {

   

        char left  = (char) 65;

        long right = 70;

   

        if (left >  50 && right == 70 ) { Console.WriteLine("left  > 50 AND right == 70"); }

        if (left !=  4 || right >  90 ) { Console.WriteLine("left != 4  OR  right >  90"); }

        if (           ! (left  == 80)) { Console.WriteLine("left is NOT equal to 80   "); }

   

      }

   

    }