How can I add elements into array that have already elements?

Hello this is my first time using uipath studio
I am try to insert in a array variable type String a new value (like in javascript you use array.push(“element”)).

In my case i have in a secuence assing activity array = {“name1”, “name2”} so i want to do another assig activity that push “name3”, but if I put array(2) = “name3” I have an error: index was outside the bounds of the array

I try too put in the default field of the array variable New String(10){} but nothing

1 Like

hi @Rodrigo_Munoz1,

Create an array variable and assign

arrVar = New String(10){}
arrVar(0) = “arr1”
arrVar(1) = “arr2”
arrVar(2) = “arr3”

Else instead of array use List<String>

3 Likes

thanks for your quickly answer, so I undertand if I introudece activity array = {“name1”, “name2”} I made actomatically the array lengh 2 right?

Yep right, in array you cannot increase the size at runtime.

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.