Adding a double value to ArrayList

  • Thread starter Thread starter San
  • Start date Start date
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
 
..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
 
Back
Top