Under what circumstance will the following code print: “value != 42, what is wrong?”

 

I tested this quiz out on Lutz, his first question was “does it use reflection”… typical from the reflector guy ;-)

Anyway, nope, no “funny business”… It is 100% verifiable code that would pass just about any code review.  

 

 

public class Derived: Base

{

    private int value;

    public Derived()

    {

        value = 42;

    }

 

    public override void Method1()

    {

        if (value == 42) Console.WriteLine("value == 42, all is good");

        else Console.WriteLine("value != 42, what is wrong?");

    }

}