다음을 정의했습니다.
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++)
Items를 IEnumerable로 정의해도됩니까?