Posts

Showing posts with the label C# | IList Vs IEnumerable Vs ICollection

C# | IList Vs IEnumerable Vs ICollection

Generally, developers are confused about when and why should they use IEnumerable OR ICollection OR IList Or List. So, in this article, I am exploring more when and why to use each. When and why we should choose IEnumerable This is the base interface for any collection under system.Collection. If you want iteration only, then it is the best choice to use. Iteration means that you do not want any index based search or any write or any insert or remove.(only read records). You can only read records, nothing else. public   interface  IEnumerable {        // Summary:         // Returns an enumerator that iterates through a collection.         //         // Returns:         // An System.Collections.IEnumerator object that can be used to...