I've got a class that I inherited from the Generic List class -
public class InfoList:List<Info>
It all works the way I expect it to except when I try and do this - I delcare a InfoList, and do a findAll from it :
The FindAll method returns a List<Info> object which makes sense, but since InfoList inherits from List<Info> I thought I could just do the cast - But when I do that I get an Unable to cast object of type generic list to type of InfoList. If I remove the cast then it won't compile - So, do I have to iterate thru the List<Info> and store those in the InfoList, or is there a way to make this work in one shot? I've been searching google and haven't found any relevant links (yet).
Thanks in advance.
public class InfoList:List<Info>
It all works the way I expect it to except when I try and do this - I delcare a InfoList, and do a findAll from it :
Code:
InfoList tempList = new InfoList()
Predicate<Info> tempFilter;
HistoryFilter filter = new HistoryFilter(HistoryFilterDescription);
tempFilter = new Predicate<Info>(filter.FilterByHistory);
InfoList returnList = (InfoList)tempList.FindAll(tempFilter);
The FindAll method returns a List<Info> object which makes sense, but since InfoList inherits from List<Info> I thought I could just do the cast - But when I do that I get an Unable to cast object of type generic list to type of InfoList. If I remove the cast then it won't compile - So, do I have to iterate thru the List<Info> and store those in the InfoList, or is there a way to make this work in one shot? I've been searching google and haven't found any relevant links (yet).
Thanks in advance.