Of course, these are chains from one constructor to another. There are two forms - this for binding to another constructor in the same class and base for binding to another constructor of the base class. The body of the constructor you are hooking is executed, and then the body of your constructor is executed. (Of course, another constructor may grab onto another one first.)
If you do not specify anything, it is automatically bound to the constructor without parameters in the base class. So:
public Foo(int x) {
equivalently
public Foo(int x) : base() {
Note that instance variable initializers are executed before another constructor is called.
Surprisingly, the C # compiler does not detect that you will end up with mutual recursion, so this code is valid, but will end up with a stack overflow:
public class Broken { public Broken() : this("Whoops") { } public Broken(string error) : this() { } }
(However, this prevents you from binding to the same constructor signature.)
See my article on the constructor chain for more details.
Jon skeet
source share