Got a question about looping though controls and disposing them.
In the first example the application skips roughly 1/3 of the JustAClass'es.. while in the second example all of them are disposed.
Any ideas of why?
In the first example the application skips roughly 1/3 of the JustAClass'es.. while in the second example all of them are disposed.
Any ideas of why?
VB.NET:
For Each c As Control In Me.Controls
If TypeOf c Is JustAClass Then
c.Dispose()
End If
Next
VB.NET:
Dim JustAClassDelete As New List(Of JustAClass )
For Each c As Control In Me.Controls
If TypeOf c Is JustAClass Then
JustAClassDelete.Add(c)
End If
Next
For i = 0 To JustAClassDelete.Count - 1
JustAClassDelete.Item(i).Dispose()
Next