G
Guest
Hello all,
I have written the following code that both enumerates and also removes from
the collection being enumerated. As the code illustrates, this causes me to
have to reset the enumerator. Clearly this isn't very attractive.
Dim enumerator As IEnumerator = _containmentTree.GetEnumerator
While (enumerator.MoveNext)
Dim classProxy As G2ProxyBase = CType(enumerator.Current, G2ProxyBase)
Dim proxyName As String = classProxy.Name
If Not _topLevelAssets.Contains(proxyName) Then
_containmentTree.Remove(classProxy)
enumerator = _containmentTree.GetEnumerator
End If
End While
I'm sure there is a better way, but I haven't thought of it yet. What do you
others think?
I have written the following code that both enumerates and also removes from
the collection being enumerated. As the code illustrates, this causes me to
have to reset the enumerator. Clearly this isn't very attractive.
Dim enumerator As IEnumerator = _containmentTree.GetEnumerator
While (enumerator.MoveNext)
Dim classProxy As G2ProxyBase = CType(enumerator.Current, G2ProxyBase)
Dim proxyName As String = classProxy.Name
If Not _topLevelAssets.Contains(proxyName) Then
_containmentTree.Remove(classProxy)
enumerator = _containmentTree.GetEnumerator
End If
End While
I'm sure there is a better way, but I haven't thought of it yet. What do you
others think?