Exercises in this lecture               Go to the notes, in which this exercise belongs -- Keyboard shortcut: 'u'   Alphabetic index   Course home      

Exercise 4.2
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?