Exercises in this lecture              Go to the slide, where this exercise belongs -- Keyboard shortcut: 'u'  

Exercise 4.1
Equality of value types and reference types


Take a close look at the following program which uses the == operator on integers.

using System;

class WorderingAboutEquality{

  public static void Main(){
    int i = 5,
        j = 5;

    object m = 5,
           n = 5;  

    Console.WriteLine(i == j);
    Console.WriteLine(m == n);
  }

}

Predict the result of the program. Compile and run the program, and explain the results. Were your predictions correct?


Solution