First (which works) :
IEnumerable<PacchettoOfferta> PacchettiTemp = from PacchettoOfferta a in SottoPagina.PacchettiOfferte
select a;
Pacchetti = Pacchetti.Union(PacchettiTemp);
Second (which doesn’t work, Unable to cast object of type) :
Pacchetti = Pacchetti.Union((IEnumerable<PacchettoOfferta>)SottoPagina.PacchettiOfferte);
Why? I’d like to use the second statement… What are the differences? And what do I need to do in order to fix it?
If
SottoPagina.PacchettiOfferteis not anIEnumerable<PacchettoOfferta>, you can’t cast it to this type.Try using the Enumerable.Cast Extension Method: