Dynamic Arrays in C++\CLI

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.
 
C

Carl Daniel [VC++ MVP]

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
 
H

Herby

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?
 
G

Guest

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);
}
 

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