Best way to remove items from a List(Of ...) - 01-11-2012 , 12:08 AM
Lets say that I have two classes, ClassA and ClassB. Further suppose
that ClassA has, as one of it's properties, a List(Of ClassB). For
Public Class ClassA
Private _Property1 as integer
Private _Property2 as List(Of ClassB)
Public Property Property1 as integer
Public Readonly Property Property2 as List(Of ClassB)
Now, one of the properties in ClassB is IsToBeDeleted. What I want to
be able to do is to delete each of the ClassB items in the List(Of
ClassB) if their IsToBeDeleted property = True.
What is the best way to implement something like this?
I tried the following, but this doesn't work...
For Each oClassB As ClassB In _Property2
If (oAssociatedIso.IsToBeRemoved = True) Then
_ItemsWereRemovedFrom = True
Once an item is removed from the List, the collection has changes and
the Next statement raises an exception as a result.
Re: Best way to remove items from a List(Of ...) - 01-11-2012 , 03:47 AM
|Thread Tools||Search this Thread|