私は以下を定義しました:
public ICollection<Item> Items { get; set; }
このコードを実行すると:
Items = _item.Get("001");
次のメッセージが表示されます。
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?)
誰かが私が間違っていることを説明できますか?Enumerable、Collections、およびToList()の使用の違いについて非常に混乱しています。
追加情報
私のコードの後半には、次のものがあります。
for (var index = 0; index < Items.Count(); index++)
アイテムをIEnumerableとして定義しても大丈夫ですか?