PC Review


Reply
Thread Tools Rate Thread

collection remove

 
 
Frank
Guest
Posts: n/a
 
      15th Jul 2004
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


 
Reply With Quote
 
 
 
 
Ken Tucker [MVP]
Guest
Posts: n/a
 
      15th Jul 2004
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" <(E-Mail Removed)> wrote in message
news:cd5g1p$fu9$(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen Microsoft ASP .NET 1 18th May 2007 10:24 AM
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen Microsoft Dot NET 1 18th May 2007 10:24 AM
DataGridView - Custom Collection - Remove New Row from Collection =?Utf-8?B?V2ViYmVydA==?= Microsoft Dot NET 0 8th Sep 2006 12:09 PM
Cannot remove item from collection =?Utf-8?B?S291IFZhbmc=?= Microsoft Excel Programming 1 31st Jan 2006 08:24 PM
Collection remove Franck Diastein Microsoft C# .NET 7 17th Feb 2005 08:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:51 PM.