Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
is there a methode to insert a new string to a specified index within an existing CLI String^ array?
starting with:
Java
array<String^>^ trio = {"Paul","Mary"};

// ... insertion code...
// and get a result as if ...
Java
array<String^>^ trio = {"Peter","Paul","Mary"};

was initialized?
thanks a lot
Lino

What I have tried:

googled a lot, carefully read
- ... especialy:
- MSDN: Chapter 4 Arrays, Strings, and Pointers
- Nish Nishdan: Arrays in C++/CLI
Posted
Updated 27-Apr-16 2:34am

1 solution

Arrays are immutable. Once created they cannot be changed without allocating a new array and inserting the object where you want it while you copy the old array content to the new one.
 
Share this answer
 
Comments
Richard Deeming 27-Apr-16 8:54am    
Are they really immutable - i.e. you can't change the contents - or are they just fixed-size?
Dave Kreskowiak 27-Apr-16 9:49am    
The array itself is, the content is not, unless it's a string of course. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900