I have a List<>
of abstract objects that contains different types of objects.
I am trying to grab all the items of a certain type and set those items to their own List<>
.
This is not working -
//myAbstractItems is a List<myAbstractItem>
//typeAList inherents from myAbstractItem
var typeAList = ((List<itemTypeA>)myAbstractItems.Where(i => i.GetType() == typeof(itemTypeA)).ToList());
The casting (List<itemTypeA>)
appears to be failing.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…