dumb remove question

  • Thread starter Thread starter news
  • Start date Start date
N

news

Well here's a sample of the code:

class someobject{};
ArrayList alist;

alist = new ArrayList();

for(int i = 0; i<10;++i)
alist.Add(new someobject());




OK now how do I get rid of the 10 objects in alist?

Does Remove remove the object and delete it. Or does it just remeove it from
the list?

If it doesn't, how do I delete the objects?


Thanks,
Bill
 
Well here's a sample of the code:

class someobject{};
ArrayList alist;

alist = new ArrayList();

for(int i = 0; i<10;++i)
alist.Add(new someobject());

OK now how do I get rid of the 10 objects in alist?
alist.Clear();

Does Remove remove the object and delete it. Or does it just remeove it from
the list?

Just remove it from the list. Note that the object itself isn't in the
list - just a reference to the object.
If it doesn't, how do I delete the objects?

Why do you want to delete the objects in the first place? That's what
the garbage collector is for.

Jon
 

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