·  C# – Syntax – Operators – Comparison

 

- Info:

  - This tutorial shows how to use Comparison Operators in C#.: == != < <= > >= instanceof.

 

- 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 == right) { Console.WriteLine("Left    equals            right."); }

        if (left != right) { Console.WriteLine("Left is different from    right."); }

        if (left <  right) { Console.WriteLine("Left is smaller then      right."); }

        if (left <= right) { Console.WriteLine("Left is smaller or equals right."); }

        if (left >  right) { Console.WriteLine("Left is greater then      right."); }

        if (left >= right) { Console.WriteLine("Left is greater or equals right."); }

       

      }

   

    }