Illustrates the use of the comparison operators

image_pdfimage_print

   
 
/*
Mastering Visual C# .NET
by Jason Price, Mike Gunderloy

Publisher: Sybex;
ISBN: 0782129110
*/

/*
  Example3_3.cs illustrates the use of
  the comparison operators
*/

public class Example3_3
{

  public static void Main()
  {

    bool result;

    // false expressions
    result = 10 == 1;
    System.Console.WriteLine("10 == 1 is " + result);
    result = 10 < 1;
    System.Console.WriteLine("10 < 1 is " + result);
    result = 10 <= 1;
    System.Console.WriteLine("10 <= 1 is " + result);

    // true expressions
    result = 10 != 1;
    System.Console.WriteLine("10 != 1 is " + result);
    result = 10 > 1;
    System.Console.WriteLine("10 > 1 is " + result);
    result = 10 >= 1;
    System.Console.WriteLine("10 >= 1 is " + result);
    int intValue1 = 10;
    int intValue2 = 1;
    result = intValue1 != intValue2;
    System.Console.WriteLine("intValue1 != intValue2 is " + result);

  }

}