clone of an inherited generic list
Posted on 2010-08-27
I have a class "NavigationElement", where I implemented a clone method.
Then I have a generic List that inherits from a list of this objects (NavigationElement)
public class NavigationElementsList<NavigationElement> : List<NavigationElement>, ICloneable
in this list I also implemented the
public Object Clone()
now I need to call the FindAll method in an istance of this NavigationElementsList<NavigationElement>, but this is not possible because the returned type is not the same as the generic List<T>.
I need to have a deep copy of the list because I'm going to change the values of the properties and this will cause a change in the referenced items in the original list<T> that I want to avoid.
This also won't work:
public NavigationElementsList<T> FindAll(Predicate<T> match)