Question: I have a class B which derives from another class A. Class A implements a Copy method. How can I implement a Copy method in class B which makes use of A.Copy() ?

There are reasons (possibly not good ones) why I have not used Clone and why I would like to have this inheritance structure.

```
class A 
{
    ... properties ...
    public A Copy()
    {
        ...copy properties....
    }
}

class B : A 
{
    ... one extra property ...
    public B Copy()
    {
        // how to copy base()??
        ...copy extra propertie....
    }
}

```

Answer: 
A common solution is to define a constructor that copies all properties from another instance. Derived classes then copy the properties defined in their class and call the base constructor to copy the properties of the base class.

```
class A 
{
    // properties

    protected A(A other)
    {
        // copy properties
    }

    public A Clone()
    {
        A clone = CloneCore() as A;
        if (clone == null)
            throw new NotImplementedException("Clone Not Implemented Correctly");
        return clone;
    }

    protected virtual object CloneCore()
    {
        return new A(this);
    }
}

```

```
class B : A 
{
    // one extra property

    protected B(B other) : base(other)
    {
        // copy extra property
    }

    public new B Clone()
    {
        B clone = CloneCore() as B;
        if (clone == null)
            throw new NotImplementedException("Clone Not Implemented Correctly");
        return clone;
    }

    protected override object CloneCore()
    {
        return new B(this);
    }
}

```
You can use the [base](http://msdn.microsoft.com/en-us/library/hfw7t1ce%28v=vs.110%29.aspx) keyword, which is used to access members of the parent class.

```
class B : A 
{
    ... extra properties ...
    public B Copy()
    {
        base.Copy();
        ... copy extra properties ...
    }
}

```