Adding a double value to ArrayList

S

San

Hi,
I'm using a Managed C++ project with MFC support. I have an ArrayList
pointer object alValue (ArrayList* alValue) to this object i want to add all
the elements present in Vector<double> vVector to it..

I'm using this line of code..

alValue->Add (new System::Double(vVector))

and I'm getting the following compilation error..

error C2664: 'System::Collections::ArrayList::Add' : cannot convert
parameter 1 from 'double __gc *' to 'System::Object __gc *'

can somebody please tell me proper way of adding a double value to the
arraylist.

Thanks in advance..
San
 
T

Tamas Demjen

..NET containers can only store .NET objects (System::Object
descendants). It's not like the STL that can store anything. You have to
box your double value.

container->Add(__box(double_value));

Tom
 

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

Top