Daily question: Fun with constructors
It’s been a while since anyone has posted a daily question, but here’s one to get y’all in the mood…
Given the following code:
public class BaseClass {
public BaseClass() : this("Base value") {
Console.WriteLine("Base: Empty");
}
public BaseClass(object value) {
Console.WriteLine("Base with value: {0}", value);
}
}
public class DerivedClass : BaseClass {
public DerivedClass() : this("Derived value") {
Console.WriteLine("Derived: Empty");
}
public DerivedClass(object value) : base(value) {
Console.WriteLine("Derived with value: {0}", value);
}
}
What will be printed to the console when a new DerivedClass object is created using the default DerivedClass constructor:
new DerivedClass();
First person to post the correct answer wins a prize consiting solely of that warm fuzzy feeling you get by being the first person to answer a question correctly.

I just wish I had a compiler :)
Also, what version of Coldfusion are you using? There’s no such thing as a constructor in MX 6.1?
I’m guessing this:
Base with value: Derived value
Derived with value: Derived value
Derived: Empty
But am happy to concede that the execution order for : this(..) is different to : base(…) and thus could be wrong.
Nope, you’re absolutely right Bender. Good one; it was a bit of a trick question!
Base with value: Derived value
Derived with value: Derived value
Derived: Empty