views:

34

answers:

1

given this class definition:

  public class Frame
    {
        IFrameStream CapturedFrom;
    }

I want implement Clone() method in this class, but problem is:

How to create the IFrameStream field in the destination instance? - I just don't know its implementation, how to create the instance?

+1  A: 

Think of the semantics. In other words, what does the CapturedFrom field mean?

From your code, I assume that it would make sense to set the CapturedFrom field of the new instance in the Clone() method to the same value as the CapturedFrom field of the source instance. This is what's usually known as a "shallow copy".

Alternatively, you can leave it null. After all, the new instance hasn't been captured from a stream but cloned anew.

CesarGon