c# - Change objects in an enumerable collection -


i have collection cannot iterated through (via index), implement ienumerable.

is there way replace objects in collection when enumerating though it? know not possible in foreach loop, seems reasonable thing want do.

i went far consider using c#'s pointers, don't work managed types.

i know can populate array of data, , edit way, but

  1. that seems wasteful
  2. far more importantly, loses entire structure.

for example purposes:

public void example(object a,object b, object c) {     object[] ex = {a,b,c};     object d = new mycustomtype(); } 

without using indexers, how can make ex hold {a,d,c}? assume way can access ex through enumerator. there no add or addat methods in type (played here object[]. assume underlying structure unknown/highly complex.

how can this?

as payo said, statement conflict each other. cannot iterate through ienumerable yet in foreach loop, iteration. , ienumerable pretty says can enumerate through collection. here input on question:

when enumerating through collection limited on attempt change data enumerating through. , cannot delete anything. in part due potential of changing enumeration.

a possible approach create list of items, enumerate through list , put want list. reload ienumerable assuming expose .add(ienumerable list).

in 1 situation had items wanted delete ienumerable, did foreach, tracked each object wanted remove, after enumeration did remove of each object had saved.

nowadays, linq, can more removing objects if can phrase define query of want (leaving out not want) process against iqueriable result set.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -