![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Remove items from ArrayList Hi, I have an array list in which some items are marked as "ShouldRemove". When I loop through each item, I should remove these items. However, I believe that I will get "Collection was modified; enumeration operation may not execute" error. foreach (BenchmarkPrice bp in mBenchmarkPriceList) { if (bp.ShouldRemove == true) { // This won't work because this alters the length of the array list, mBenchmarkPriceList mBenchmarkPriceList.Remove (bp); } } Any advice on how to get this done safely? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Remove items from ArrayList On Fri, 27 Mar 2009 06:59:35 -0700 (PDT), Curious <fir5tsight@xxxxxx> wrote: Quote: >Hi, > >I have an array list in which some items are marked as "ShouldRemove". >When I loop through each item, I should remove these items. However, I >believe that I will get "Collection was modified; enumeration >operation may not execute" error. > > foreach (BenchmarkPrice bp in mBenchmarkPriceList) > { > if (bp.ShouldRemove == true) > { > // This won't work because this alters the length >of the array list, mBenchmarkPriceList > mBenchmarkPriceList.Remove (bp); > } > } > >Any advice on how to get this done safely? end to the beginning: For indx As Integer = mBenchmarkPriceList.Count - 1 TO 1 STEP -1 Dim bp As BenchMarkPrice = mBenchmarkPriceList(indx) ... |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| How to remove recognize/remove items under "Services" tag in SYSTEM CONFIG window? | General Discussion | |||
| Loop only the last 10 items in arraylist | .NET General | |||
| How to remove function: items at startup | PowerShell | |||
| Thread-safety: Change property of items in arraylist versus removingitems from the arraylist | .NET General | |||
| remove items from index manually | Vista file management | |||