Team LiB
Previous Section Next Section

Logical Operators

Logical operators are used to combine two expressions into logical expressions. There are three logical operators:

The following is an example of using logical operators.

Code Example: Logical Operators
Start example
using System;

namespace Client.Chapter_2___ Expressions_and_Operators
{
       class RelationalOperators2
      {
            static void Main(string[] args)
            {
                  int a = 10, b = 20, c = 30;
                  if (a < 15 && b < 20)
                        c = 10;
                  if (a < 15 || b < 20)
                        c = 15;
                  if (!(a == 15))
                        c = 25;
            }
      }
}
End example

Team LiB
Previous Section Next Section