Was converting some code from VB.Net to C#, when I came across this, in some code using the Ionic Zip library:
Dim zipEntry1 As ZipEntry = zipFile1.Entries(0
Strictly viewed, ICollection
is an interface to an unordered collection of elements (more precisely, a collection whose elements cannot individually be accessed by their index). That is just by definition.
But you can still use LINQ's ElementAt(int index)
extension method. That would just iterate through all elements index
times every time you call it (so it is generally slower).
NOTE: ICollection
is not to be confused with Collection
. The latter implements IList
(among other things), which by definition does specify that each element can be accessed by its index.