Illustrates the use of the Boolean logical operators
/*
Mastering Visual C# .NET
by Jason Price, Mike Gunderloy
Publisher: Sybex;
ISBN: 0782129110
*/
/*
Example3_4.cs illustrates the use of
the Boolean logical operators
*/
public class Example3_4
{
public static void Main()
{
bool result;
// use of the Boolean logical AND operator
result = (1 == 1) && (2 > 1);
System.Console.WriteLine("(1 == 1) && (2 > 1) is " + result);
result = (1 == 1) && (2 < 1);
System.Console.WriteLine("(1 == 1) && (2 < 1) is " + result);
// use of the Boolean logical OR operator
result = (1 == 1) || (1 == 0);
System.Console.WriteLine("(1 == 1) || (1 == 0) is " + result);
result = (1 == 0) || (1 == 0);
System.Console.WriteLine("(1 == 0) || (1 == 0) is " + result);
// use of the Boolean logical NOT operator
result = !(1 == 0);
System.Console.WriteLine("!(1 == 0) is " + result);
result = !(1 == 1);
System.Console.WriteLine("!(1 == 1) is " + result);
}
}