[Mono-list] Calling a constructor from within another's code
Francisco M. Marzoa
fmmarzoa at gmx.net
Tue Nov 16 13:35:20 EST 2010
I know you can call a base class constructor using ": base" after the
new constructor signature. I.e.:
public class A
public A (int _i)
public class B : A
public B (int a, int b) : base (a+b) // Calls A constructor with _i
But what happens if you should made some more complicated that cannot be
done in that way???
public class C : B
public C ()
MyDataStruct data = GetDataFromTheDatabase ();
base ( data.a, data.b ); // This will not work, indeed, but
illustrates the idea...
This is a question more focused on C# than in mono itself, but I hope
not to disturb no one doing it here since the list has not very high trafic.
More information about the Mono-list