Quantcast
Channel: User Chris W. Rea - Stack Overflow
Viewing all articles
Browse latest Browse all 42

Comment by Chris W. Rea on Why ICollection index does not work when instantiated?

$
0
0
@Inanikian There is no "best"; it depends on context. If you must use methods in IList<T>, say if you require indexing/ordering, then IList<T> may be the best interface type to require. If, on the other hand, you only care to count, add, remove, and enumerate items, but never by index, and don't want to impose a requirement of additional functionality on a class to have an indexer and all the other functionality implied by IList<T> that you wouldn't use anyway, then it may be better to require only what you need, e.g., ICollection<T> (or even IEnumerable<T>, if you aren't modifying anything).

Viewing all articles
Browse latest Browse all 42

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>