#using <mscorlib.dll>
using namespace System;
using namespace System::Collections;
int main()
{
ArrayList *list = new ArrayList();
list->Add(__box(54));
list->Add(__box(32));
Console::WriteLine(S"The first value is {0} and the second is {1}.",
/* what to write here */, /* and here */ );
}
I have tried list[0] and *list, but that doesn''t work. How do you access the elements?
MC++ ArrayList, accessing elements
You can use the property syntax as well:
Only the indexer-style like in C# (theList[5]) does not work.
Regards,
Andre (VizOne) Loker
theList->Item[5];
Only the indexer-style like in C# (theList[5]) does not work.
Regards,
Andre (VizOne) Loker
You should also delete the ArrayList when done. You never call delete on it. I know C# has garbage collection, but it''s a bad habbit to not clean memory. What if the application would run 24/7 and allocation memory in a loop?
Toolmaker
-Earth is 98% full. Please delete anybody you can.
Toolmaker
-Earth is 98% full. Please delete anybody you can.
quote:Original post by Toolmaker
You should also delete the ArrayList when done. You never call delete on it. I know C# has garbage collection, but it''s a bad habbit to not clean memory. What if the application would run 24/7 and allocation memory in a loop?
Don''t program much Managed C++ do you? Calling delete on an ArrayList pointer will generate a compiler error.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement