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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top