J
Jon Skeet [C# MVP]
Joanna Carter said:| Nope. Otherwise virtual method calls being made from the constructor
| couldn't run the overridden implementation in the derived class, which
| they do.
Huh ? You lost me there.
Actually, having reread your statement, mine indeed doesn't follow.
However, the fact that variables can be set before the base class
constructor is executed shows that to some extent at least, the object
*does* exist - the memory must have been allocated, at least, otherwise
those variables wouldn't exist.
| In fact, C# *does* run code before the base class constructor - it
| executes the variable initialisers. (Note that this is different from
| Java, which doesn't even execute the variable initializers before
| running the superclass constructor.)
Picky !
| I usually find there are ways round this when I really want to do
| something before the constructor code is executed.
Like... ?
Like the ways we've already shown, executing static methods etc.