मैंने निम्नलिखित को परिभाषित किया है:
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, संग्रह और ToList का उपयोग करने के बीच अंतर के बारे में बहुत उलझन में हूँ ()
जानकारी जोड़ी गई
मेरे कोड में बाद में मेरे पास निम्नलिखित हैं:
for (var index = 0; index < Items.Count(); index++)
क्या मैं आइटम को IEnumerable के रूप में परिभाषित करना ठीक होगा?