Add string at the end of array

Hello friends,
@rkelchuri, @Ninett_Panfir, @Rammohan91, @balupad14, @Florent_Salendres, @vvaidya, @Palaniyappan, @ClaytonM, @vvaidya, @lakshman, @Dave

I have to add elements at the end of an array with no fixed lenght.
Each time I have a new string I must add it at the end of th e array.
How to do that?
Thank you so much,
Cami

2 Likes

i think for this we need to use list because array length is fixed and it must be initiallzed in the very beginning as well
for adding to list we can use ADD TO COLLECTIONS activity
where in items mention the value
and in collections mention the list variable name

Cheers @CamiCat

2 Likes

Thank you @Palaniyappan,
can you please share screnshots or xaml?
Tank you,
Cami

1 Like

You should use a list instead of an array. You can add/remove any amount of items to a list

1 Like

yah sure
–hope these steps wuld help you resolve this
–in the variable panel create a list variable like this
variablename = in_liststring
variabletype = System.Collections.Generic.List(string) (we can take any type we want)
variablescope = whole sequence
variablevalue = New List(of string) or
if we have a list variable with values in it defined then New List(of string) from {“value1”,“value2”,“value3”}

–now use a ADD TO COLLECTION activity next to this assign activity and in the property panel
for items mention as “yourstringvalue” (here string as list of type string is created or we can also create list of int32 as well)
then
for collections mention as in_liststring
and type argument as string

–this will add the string value at last to the list variable

hope this would help you
Cheers @CamiCat

2 Likes

were we able to add them now buddy @CamiCat

2 Likes

use as follows:

stringMax = UBound(ArryOutPut)

1 Like

Just to add, there might be times when you should use Arrays, which then you would use .Concat() to join arrays. For example, {1,2,3}.Concat({4,5,6}) or {1,2,3,4,5}.Concat({6}) which both would result to {1,2,3,4,5,6}

But, I agree that Lists should be used if “during” the process you will be adding to it. So it might depend more on why or what you are adding to the array to determine if Lists is the best approach.

2 Likes

Thank you so much @Palaniyappan.
Is it possible to convert back List with all the elements to string?
Thank you,
Cami

1 Like

Yah of course
String.Join(“,”,yourlistvariable)

This will join all the elements in the list with comma in between them

Cheers @CamiCat

1 Like

Thank you so much @Palaniyappan.
If I initialize a list of string and I pass it in the “Add to collection” activity, I get this message:


How to add several items to a collection/list and then convert back to a unique string?
Thank you,
Cami

1 Like

You have to change the TypeArgument to string. You currently have it set to object and the error message is saying it is expecting it to be list<string> instead

2 Likes

Thank you so much for your precious help @Palaniyappan.
You always give me precious advices.
Thank you so much.
Camilla.

2 Likes

no worries
were we able to get this
any other queries
Cheers @CamiCat

2 Likes

we need to change the type argument as string
cheers @CamiCat

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