collection remove

  • Thread starter Thread starter Frank
  • Start date Start date
F

Frank

Hello,
I use a collection to store objects. If I want to remove all objects, is it
good programming practice to set the collection to nothing? Or should I
remove every object individually? Any pro's or con's to consider?
Thanks
Frank
 
Hi,

If you are going to continue to use the collection I would remove all
the items rather than set the collection to nothing and have to recreate it.
Dim col As New Collection

For i As Integer = 0 To 100

col.Add(String.Format("Item{0}", i))

Next

For x As Integer = col.Count To 1 Step -1

col.Remove(x)

Next



Ken
 
Back
Top