Zagiel

Zagiel

  • NA
  • 7
  • 0

How to call parent constructor? Not base one.

Apr 6 2009 1:59 PM
public class A { int a; public A(int a) {this.a = a;} }
public class AB : A { int a; int b; public AB(int a, int b) : base(a) { this.b = b; } }
public class ABC : AB { int a; int b; int c; public ABC(int a, int b, int c) : AB(a, b) { this.c = c; } }
The call of AB(a, b) in ABC() is forbidden. All I can use there seems to be this() or base(). Is there a way to call the constructor of the closest parent, not the one of the oldest ancestor?

Answers (3)