I have defined the following:
public ICollection<Item> Items { get; set; }
When I run this code:
Items = _item.Get("001");
I get the following message:
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?)
Can someone explain what I am doing wrong. I am very confused about the difference between Enumerable, Collections and using the ToList()
Added information
Later in my code I have the following:
for (var index = 0; index < Items.Count(); index++)
Would I be okay to define Items as an IEnumerable?
See Question&Answers more detail:os