Zdefiniowałem co następuje:
public ICollection<Item> Items { get; set; }
Kiedy uruchamiam ten kod:
Items = _item.Get("001");
Otrzymuję następujący komunikat:
Error 3
Cannot implicitly convert type
'System.Collections.Generic.IEnumerable<Storage.Models.Item>' to
'System.Collections.Generic.ICollection<Storage.Models.Item>'.
An explicit conversion exists (are you missing a cast?)
Czy ktoś może wyjaśnić, co robię źle. Jestem bardzo zdezorientowany różnicą między Enumerable, Collections i użyciem ToList ()
Dodatkowe informacje
Później w moim kodzie mam:
for (var index = 0; index < Items.Count(); index++)
Czy byłbym w stanie zdefiniować elementy jako IEnumerable?