How to add list of string type and array of string type in uipath

I have array of string initialized with 3 items and I have List of string initialized with 2 items.How to combine them into single 5-item collection.

@tharaninatarajan1901

Please try this varArray.ToList.AddRange(varList).ToArray

cheers

Getting error “to list is not member of string()”

Hi @tharaninatarajan1901 ,

You can use the .concat function
image

Regards,

3 Likes

@tharaninatarajan1901

Please try this

ArrayVar.Union(ListVar).ToArray

cheers

It worked.Thanks

1 Like

Thanks .Can we use For Each activity to iterate through listVar and add each item to arrayB? or Add To Collection activity with arrayB as the parameter?

@tharaninatarajan1901

Array is immutable…so cannot add items to it…To list we can do as you said

cheers

Thanks .Can we use Add To Collection activity with arrayVar as the parameter?

@tharaninatarajan1901

No we cannot…to array you cannot add items…

Add to collection works with a list but not array

Cheers

1 Like

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