This article explains how to clone a custom Line entity. Custom entities can be easily cloned adding the protected copy constructor and overriding the Clone()
method. A complete example follows.
class MyLine : Line
{
private float price;
public MyLine(double x1, double y1, double x2, double y2, float thePrice)
: base(x1, y1, x2, y2)
{
price = thePrice;
}
protected MyLine(MyLine another)
: base(another)
{
price = another.price;
}
public override object Clone()
{
return new MyLine(this);
}
}
Comments
Please sign in to leave a comment.