Click here to Skip to main content
15,886,873 members
Home / Discussions / C#
   

C#

 
QuestionDeleting objects from a collection Pin
Trollslayer17-Oct-09 10:34
mentorTrollslayer17-Oct-09 10:34 
AnswerRe: Deleting objects from a collection Pin
Not Active17-Oct-09 12:01
mentorNot Active17-Oct-09 12:01 
GeneralRe: Deleting objects from a collection Pin
Trollslayer17-Oct-09 12:19
mentorTrollslayer17-Oct-09 12:19 
AnswerRe: Deleting objects from a collection Pin
Luc Pattyn17-Oct-09 12:11
sitebuilderLuc Pattyn17-Oct-09 12:11 
GeneralRe: Deleting objects from a collection Pin
Trollslayer17-Oct-09 12:27
mentorTrollslayer17-Oct-09 12:27 
GeneralRe: Deleting objects from a collection Pin
CaptainSeeSharp17-Oct-09 13:16
CaptainSeeSharp17-Oct-09 13:16 
GeneralRe: Deleting objects from a collection Pin
Luc Pattyn17-Oct-09 13:26
sitebuilderLuc Pattyn17-Oct-09 13:26 
AnswerRe: Deleting objects from a collection Pin
DaveyM6917-Oct-09 12:51
professionalDaveyM6917-Oct-09 12:51 
I'm a little confused... you want to keep the reference to the object you created in your array list, but you want to destroy it? If you destroy it, the reference will no longer be valid anyway.

If you mean you want to destroy the object and not keep a reference, so long as myAL[0] is the only reference, then it will be eligible for garbage collection when you call RemoveAt so will be destroyed automatically at some point (which can't be determined).

As Luc mentioned, if MyClass implements IDisposable then you should call Dispose() on myAL[0] before removing. If not, and MyClass is using unmanaged resources, then you should implement it yourself in MyClass.

Dave

Generic BackgroundWorker - My latest article!
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Why are you using VB6? Do you hate yourself? (Christian Graus)

GeneralRe: Deleting objects from a collection Pin
Trollslayer17-Oct-09 12:55
mentorTrollslayer17-Oct-09 12:55 
GeneralRe: Deleting objects from a collection Pin
DaveyM6917-Oct-09 13:10
professionalDaveyM6917-Oct-09 13:10 
GeneralRe: Deleting objects from a collection Pin
Trollslayer17-Oct-09 13:16
mentorTrollslayer17-Oct-09 13:16 
GeneralRe: Deleting objects from a collection Pin
Luc Pattyn17-Oct-09 13:33
sitebuilderLuc Pattyn17-Oct-09 13:33 
Answer[Added informatio] Deleting objects from a collection Pin
Trollslayer17-Oct-09 13:05
mentorTrollslayer17-Oct-09 13:05 
GeneralRe: [Added informatio] Deleting objects from a collection Pin
DaveyM6917-Oct-09 13:17
professionalDaveyM6917-Oct-09 13:17 
GeneralRe: [Added informatio] Deleting objects from a collection [modified] Pin
CaptainSeeSharp17-Oct-09 13:20
CaptainSeeSharp17-Oct-09 13:20 
GeneralRe: [Added informatio] Deleting objects from a collection Pin
Luc Pattyn17-Oct-09 13:36
sitebuilderLuc Pattyn17-Oct-09 13:36 
GeneralRe: [Added informatio] Deleting objects from a collection Pin
CaptainSeeSharp17-Oct-09 13:43
CaptainSeeSharp17-Oct-09 13:43 
GeneralRe: [Added informatio] Deleting objects from a collection Pin
Luc Pattyn17-Oct-09 13:53
sitebuilderLuc Pattyn17-Oct-09 13:53 
GeneralRe: [Added informatio] Deleting objects from a collection Pin
Luc Pattyn17-Oct-09 13:47
sitebuilderLuc Pattyn17-Oct-09 13:47 
GeneralRe: [Added informatio] Deleting objects from a collection Pin
harold aptroot17-Oct-09 14:09
harold aptroot17-Oct-09 14:09 
AnswerRe: Deleting objects from a collection Pin
dojohansen17-Oct-09 23:05
dojohansen17-Oct-09 23:05 
AnswerThanks everyone - results Pin
Trollslayer18-Oct-09 2:58
mentorTrollslayer18-Oct-09 2:58 
GeneralRe: Thanks everyone - results Pin
DaveyM6918-Oct-09 3:51
professionalDaveyM6918-Oct-09 3:51 
GeneralRe: Thanks everyone - results Pin
Trollslayer18-Oct-09 3:57
mentorTrollslayer18-Oct-09 3:57 
GeneralRe: Thanks everyone - results Pin
DaveyM6918-Oct-09 4:04
professionalDaveyM6918-Oct-09 4:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.