How to initialize an array data?


#1

There is an array data as follow;
$hoge
{“a”,“b”,“c”} // the number of items are unknown.

How to initialize the array ?
the following code was invalid.
$hoge = “”;
Thanks


#2

Hi @ryoryo,

To initialize string array, use the below syntax.
new string(){}

Another suggestion is to use collection variable.


#3

Thanks so much

but i found another problem…
Im pushing item to certain defined array
but errors below thrown…
Please find attached sample.
why I cannot push item array and how Can I do that.
Would you pls kindly advise me that…

Assign : Index was outside the bounds of the array.

sample.xaml (6.7 KB)


#4

It happens when the number of elements specified in the array while initializing does not match the number of elements stored.

Try new string(1){} if the length is known.
Better way to use is collection when the length is not known.