use interface. 2010/4/14 Benj Nunez <[email protected]>
> > "A collection cannot be modified while being enumerated." > > See: > http://bytes.com/topic/c-sharp/answers/765778-remove-item-arraylist-inside-foreach > > As indicated there, yours might work if you use a normal "for" > statement rather than "foreach". > If you use the former, be prepared to access each element through an > index. > > > > Regards, > > > Benj > > > > > > > > On Apr 14, 7:15 pm, Busky <[email protected]> wrote: > > Hello, > > > > I’m a newbie with C# and perhaps my question seems too foolish. Sorry > > by that. > > I’ve an object (collection type), let’s call it “oApps” that has > > several items that I need to get out. > > I know how to do that using foreach statement and everything should be > > ok. However > > I need to reset to null the identifier of the foreach statement and > > it’s not allowed within foreach. > > > > foreach (IAPP oApp in oApps) > > { > > try > > { > > axApp.Add(app.Name); > > axApp.Add(app.Id); > > axApp.Add(app.Description); > > } > > finally > > { > > if (app != null) > > { > > Marshal.ReleaseComObject(app); > > } > > } > > } > > > > My question is if I can do it using something else? > > The collection has the following extensions that think that could > > help, but unfortunately I don’t know how to implement. > > - AsQueryable > > - Cast > > - OfType > > > > I appreciate any help, > > > > Many thanks > > > -- > To unsubscribe, reply using "remove me" as the subject. >
