Quick question about gcnew

Aug 2, 2012 at 2:11am
Hi,

I'm writing a windows form application in which a have a
listBox Object. In first it's empty. To add items I just say:

 
myForm->myListBox->Items->Add(gcnew Object());


more specifically:

1
2
Object^ myObj = gcnew Object();
myForm->myListBox->Items->Add(myObj);


Now the question, propably a noob's one:
Do I have to worry about the "gcnew" Objects I create just
like the "new" Objects and delete them when the program closes?
Last edited on Aug 2, 2012 at 2:13am
Aug 2, 2012 at 7:47am
Do I have to worry about the "gcnew" Objects
That's the point of gcnew: No you must not delete it. gc in gcnew stands for garbage collector and that does the delete for you
Aug 2, 2012 at 10:41am
Perfect!

This is available only C++/CLI or I can use it and with C++?
Aug 2, 2012 at 10:46am
You cannot use it in C++.
Aug 3, 2012 at 3:18am
thank you for your time
Topic archived. No new replies allowed.