Andy <andy19808@hotmail.com> wrote:[color=blue]
> I've got an issue with the ICloneable interface that makes me think I'm
> missing the advantages of it.
>
> My issue is that the implemented Clone method returns an object and not
> a strongly typed definition. This means that the class you create
> exposes a method that returns an object which the user of the class must
> cast.
>
> public object Clone() {...}
>
> I would much prefer the class to expose a type of itself:
>
> public MyClass Clone() {...}
>
> so that the caller doesn't have to cast and the interface is cleaner.[/color]
You can expose that separately, and implement ICloneable explicitly.
[color=blue]
> Why should I then use IClonable??[/color]
So that things which only care that an object can be cloned can accept
instances of your class as a parameter. Not everything will always know
your concrete type...
--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too