Prime Conditional Operators Using In C# Language

Introduction

  1.   Operator ">" to compare two variable or values and see if one is bigger.
     

  2.   Operator "<" to compare two variable or values and see if one is smaller.
     

  3.   Operator "==" is use to compare two things are equal.
     

  4.   Operator "!=" is use to compare two things are not equal.
     

  5.   You can combine individual tests into one long test using the && operator for AND.
     

  6.   You can combine individual tests into one long test using the || operator for OR.

Example

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text; 

namespace condiction_operator

{

    class Program

    {

        static void Main(string[] args)

        {

            int a = 10;

            int b = 15;

            int c = 10;

            if (a > b)       //greater then operator

            {

                Console.WriteLine("a is greater then b");

            }

            else

            {

                Console.WriteLine("a is less then to b");

            }

            if (a < b)       // less then operator

            {

                Console.WriteLine("a is less then to b");

            }

            else

            {

                Console.WriteLine("a is greater then to a");

            }

            if (a == c)      // equal operator compare two values

            {

                Console.WriteLine("a is equal to c");

            }

            else

            {

                Console.WriteLine("a is  not equal to c");

            }

            if (a != c)       // not equal operator compare two values

            {

                Console.WriteLine("a is not equal to c");

            }

            else

            {

                Console.WriteLine("a is equal to c");

            }

            if (a > b && a > c) // greater then operator and AND operator compare more then two values

            {

                Console.WriteLine("a is greater then b and c");

            }

            else

            {

                Console.WriteLine("a is less then b or c, or b and c");

             }

            if (a > b || a > c) // greater then operator and OR operator, compare more then two values

            {

                Console.WriteLine("a is greater then b or c, or b and c ");

            }

            else

            {

                Console.WriteLine("a is less then b or c , or b and c");

            }

               Console.ReadLine();

        }

    }

}

Output

output.jpg


Next Recommended Reading Null Conditional Operator In C#