C# – How to chain these constructors (C#)

cconstructorconstructor-chaining

I'm just getting the concept of chaining constructors down, but I can't figure out how to chain these two particular constructors together, so I would appreciate it if somebody could help me out.

Thanks!

Constructors

// default constructor
// purpose: initialize data members to zero
// Parameters: none
// returns: none
public Line()
{
    startPoint.xCoord = 0;
    startPoint.yCoord = 0;
    endPoint.xCoord = 0;
    endPoint.yCoord = 0;
}


// parameterized constructor
// purpose: initialize data members to p1 and p2
// Parameters: Point objects p1 and p2
// returns: none
public Line(Point p1, Point p2)
{
    startPoint = p1;
    endPoint = p2;
}

Best Answer

public Line() : this(new Point(), new Point())
{
}