Dynamic Arrays in C++\CLI

  • Thread starter Thread starter Herby
  • Start date Start date
H

Herby

How do you use a dynamic array or equivalent in C++\CLI?

When using CArray in MFC its simple you say array.Add( item )
If the size needs to grow it will do that for you.

Iv tried using array<item> but understand its dimensions cannot be
changed once created.
This is very restrictive for me.

Ultimately i will be using STL\CLR but this has not been released yet
and am just trying to use a suitable substitute until its released.

Thanks in advance.
 
Herby said:
How do you use a dynamic array or equivalent in C++\CLI?

When using CArray in MFC its simple you say array.Add( item )
If the size needs to grow it will do that for you.

Iv tried using array<item> but understand its dimensions cannot be
changed once created.
This is very restrictive for me.

Ultimately i will be using STL\CLR but this has not been released yet
and am just trying to use a suitable substitute until its released.

See System::Collections::Generic::List<T>. It's basically an expandable
array.

-cd
 
Cheers.

List<T> works as i would want it to.

Can anyone confirm that STL\CLR containers will be marked
[Serializable]?
If not how would i serialize potentially 1000's of items contained
within?
 
Herby.. Don't forget ArrayList

Collections::ArrayList^ aStrings= gcnew Collections::ArrayList();
aStrings->Add("Managed");
aStrings->Add("Code");
for each (String^ s in aStrings) {
Console::WriteLine(s);
}
 
Back
Top