C# ArrayList question.

Started by
3 comments, last by thedevdan 19 years, 11 months ago
Why does it''s Clone() method return an object, instead of an ArrayList? All it does is force me to cast to an ArrayList whenever I use Clone().
Not giving is not stealing.
Advertisement
ArrayList.Clone() is an implementation of the ICloneable interface. And ICloneable.Clone() is defined to return an Object type.

edit: and C# doesn't support covariant return types.

[edited by - SiCrane on May 20, 2004 9:35:28 PM]
Thanks again, SiCrane.
Not giving is not stealing.
What is a covariant return type? Object can hold refs and boxing value types.
quote:Original post by DrGUI
What is a covariant return type?

This topic is closed to new replies.

Advertisement