L
linkspeed
Following texts are from C# spec.
The optional constructor-initializer specifies another instance
constructor to invoke before executing the statements given in the
constructor-body of this instance constructor. This is described
further in Section 10.10.1.
So this means:
public class c1
{
(1)public c1(int i) : this(i, i)
{
}
(2)public c1(int i, int j)
{
}
}
constructor (2) will be called before constructor (1).
It is OK for simple parameters. What if parameter j can only get from
a long and complex calculation? This requires the body of constructor
(1) is called before constructor (2).
How can we do this in C#?
Thanks
linkspeed
The optional constructor-initializer specifies another instance
constructor to invoke before executing the statements given in the
constructor-body of this instance constructor. This is described
further in Section 10.10.1.
So this means:
public class c1
{
(1)public c1(int i) : this(i, i)
{
}
(2)public c1(int i, int j)
{
}
}
constructor (2) will be called before constructor (1).
It is OK for simple parameters. What if parameter j can only get from
a long and complex calculation? This requires the body of constructor
(1) is called before constructor (2).
How can we do this in C#?
Thanks
linkspeed