Conditional operators in C#

C# has the following conditional operators:

OperatorMeaning
&&and
||or
!not

The following demo shows how to use them:


using System;

class Program
{
    static void Main(string[] args)
    {
        int i = 5;
        int j = 6;
        if (i == j)
        {
            Console.WriteLine("identical");
        }
        else {
            Console.WriteLine("not identical");
        }
    }
}

The output:


not identical
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.