Thanks, Cerebrus:-)
But maybe you misunderstood my question.
I explain it again.
Now I could implement class B as follows:
class B : A
{
int nB;
bool bFlag;
public B() { nB=0; bFlag=true; }
public B(string str) : base(str)
{
nB = 0; bFlag = true;
// other things to do
}
public B(int n):base(n)
{
nB = 0; bFlag = true;
// other things to do
}
}
But I think that's not beautiful, because the code to initialize nB
and bFlag is duplicated serveral times.
On the other hand, if I use this() initializer, I could implement
class in the following manner:
class B : A
{
int nB;
bool bFlag;
public B() { nB=0; bFlag=true; }
public B(string str) : this()
{
/* I HAVE TO COPY THE CODE FROM class A ctor. TO HERE */
// other things to do
}
public B(int n) : this()
{
/* I HAVE TO COPY THE CODE FROM class A ctor. TO HERE */
// other things to do
}
}
The second implementation solves the problem of duplicating the code
in the parameterless ctor., however it leads to the duplication of the
base class' constructors.
The problem here is that I don't know the way to call both this() and
base() initializers (if possible).
The link you provide shows me how to use base() and this() seperately,
but I want to use them at the same point. I compose a pseudocode to
demostrate my idea:
class B : A
{
int nB;
bool bFlag;
public B() { nB=0; bFlag=true; }
public B(string str) : this(), base(str)
{
// other things to do
}
public B(int n) : this(), base(n)
> > Thanks a lot!- Hide quoted text -
>
> - Show quoted text -