Collection readonly restriction review

  • Thread starter Thread starter Alvin Bruney
  • Start date Start date
A

Alvin Bruney

I posted this a few posts ago and nobody responded, probably because nobody
gives a rat's ass. But i'd like to suggest that the readonly restriction
when iterating a collection be reviewed. I have no idea how this is
implemented internally but the implimentation is obviously distorting the
final code implementation and promoting bad software practices.

The issue is if you iterate a collection you aren't allowed to change the
collection during iteration. The only ways I've found so far is to

1. Use an isolator class written by Eric Gu for that explicit purpose which
sits between the collection and the iteration mechanism
2. Swallow the exception and brute force match on
3. Ignore it

I won't wast your time with why 2 and 3 are shameful and criminal. 1 is
tedious. But the catch is that iterating a collection and attempting to
change it is extremely common even for newbies attempt to get up to speed.
So can we have this addressed please or somebody yell at me for not seeing
an easier way?
 
Alvin,

Use a for loop on the indexer method. Iterators are meant to be read-only (C
Sharp .NET Show). The reasoning is that iterators
are NOT thread safe and/or can be multiple refs to iterators for the same
collection.
 
Back
Top