TonyJ wrote:
Hello!
If you have private instance constructor you can then instance object from
within the class itself.
It is any point in doing this? I mean is there situation where this can be a
point doing this.
How about where you want to take mostly similar but slightly different
actions on data passed when it's coming from a different constructor? e.g.:
public class A
{
public A()
: this("some","default","values",0.01m,false)
{}
public A(string a, string b, string c, decimal d)
: this(a,b,c,d,true)
{
}
private A(string a, string b, string c, decimal d, bool hidden)
{
if (hidden)
{
// Do some automatic stuff, rather than popping
// up a dialog box and asking the user.
}
else
{
// Prompt a user for some information
}
// Do stuff common to both constructors.
}
}
Chris.