Translate

Thursday, August 30, 2012

constructor chaining

where a constructor calls another constructor in its class using the ": this()" designation as 


public Test( bool a, int b, string c )
    : this( a, b )
{
    this.m_C = c;
}
public Test( bool a, int b, float d )
    : this( a, b )
{
    this.m_D = d;
}
private Test( bool a, int b )
{
    this.m_A = a;
    this.m_B = b;
}

Basically constructor chaining is where a subclass calls its superclasses constructor which subsequentally calls its superclasses constrctor and so on.

No comments:

Post a Comment