By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,041 Members | 1,018 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,041 IT Pros & Developers. It's quick & easy.

collection remove

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

--------------------

"Frank" <fr***@frank.com> wrote in message
news:cd**********@news3.tilbu1.nb.home.nl...
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

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.