I'd agree, that sentence is a tad confusing. I think it's trying to saying that foreach is more efficient than a for loop for ImmutableList because accessing it with an index is not efficient - unlike List which uses an array and so has fast index access. I suggest you use the feedback link on that topic to pass your comments on.
Efficiency of List<T> foreach vs ImmutableList<T> foreach
Madura Dias
20
Reputation points
According to this document time complexity is the same (O(n)) of List<T>.Enumerator and ImmutableList<T>.Enumerator.
But in the description, it says
"Enumerating an ImmutableList<T>
using a foreach
loop is efficient because ImmutableList<T>
uses a binary tree to store its data instead of an array like List<T>
uses" .
This isn't very clear, how foreach on ImmutableList<T> is more efficient than the same on List<T> if the time complexity is equal ?
Developer technologies | .NET | Other
4,107 questions