Merge 2 String List

studio

#1

Hi

I have 2 string list,. Var1 and Var2.
Var1 can be of length 0 to n, Var2 can also be of length 0 to n. Need to merge them in Var1 itself.
You have any easy option. Please provide some guidance


#2

What does it mean merge?
Provide examples.

unionList = list1.Union(list2).ToList

unionDistinctList = list1.Union(list2).Distinct.ToList


#3

Eg:
Var1={‘Str1’,‘Str2’}
Var2={‘Str3’,‘Str4’}.

then I mentioned merge Var1 and Var2 to Var1 so output is
Var1= {‘Str1’,‘Str2’,‘Str3’,‘Str4’}

Var1 and Var2 will be distinct always as per requirement but possible to have 0 values


#4

Than you can use my first example:

In Assign activity
Var1 = Var1.Union(Var2).ToArray

But I recommend not use the same variable for new array. And try to use more meaningful names for variables.


#5

Thanks. your solution works fine.
Actual variable names are different, Thanks for your suggestions :slight_smile: