How to initialize an array data?

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

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

Hi @ryoryo,

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

Another suggestion is to use collection variable.


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)

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.


Here is a detailed article on that :slight_smile:

Thanks for your helpful comment!

1 Like

In C#:
new List<int>() { 2, 3, 5, 7 };
new List<string>() {"abc","xyz"}

Arrays can be init as (you need to declare the size):
new int[2]{121,232}
new string[2] {"abc","xyz"}

In short, initiate just as you would in your C# program either using assign Activity or setting Default values while declaring in variables tab