what is the pattern for modifying a collection in C#
- by macias
What is the pattern (best practice) for such problem -- modifying elements (values) in collection?
Conditions:
size of the collection is not changed (no element is deleted or added)
modification is in-place
In C++ it was easy and nice, I just iterated trough a collection and changed the elements. But in C# iterating (using enumerator) is read-only operation (speaking in terms of C++, only const_iterator is available).
So, how to do this in C#?
Example: having sequence of "1,2,3,4" modification is changing it to "1, 2, 8, 9" but not "1, 2, 3" or "1, 2, 3, 4, 5".