array<System::Object^>^ temp0 = {"Test","Test2"};
this works fine, but the problem is to create a new instance of it, I looked it up all over the internet specially msdn and I couldn't find anything related to creating a new instance and defining a size of it or allocate it dynamically.
I was thinking something like this:
array<System::Object^>^ temp0 (2) = new array<System::Object^>^();
But this obviously doesn't work. Someone know how to define new instance with defined size or without defined size? I want to be able to populate it from a for loop after like: temp0[3] = "Test3";
I hope I was clear enough. Thanks in advance.
You cannot create an array without a defined size. You can either create an array with a defined size and default-initialized elements:
array<Object^>^ temp0 = gcnew array<Object^>(numElements); // numElements is int
or with specific values:
array<String^>^ temp0 = gcnew array<String^> { L"Test", L"Test2" };