I need to call one constructor from the body of another one. How can I do that?
Basically
class foo {
public foo (int x, int y)
{
}
public foo (string s)
{
// ... do something
// Call another constructor
this (x, y); // Doesn't work
foo (x, y); // neither
}
}
Best Answer
You can't.
You'll have to find a way to chain the constructors, as in:
or move your construction code into a common setup method, like this: