Hi everyone,
I’ve 2lists as below:
list1 = (“1”,“2”,“3”,“4”…)
list2 = (“120”,“130”,“140”,“150”…)
I need to store this value in final list as
FullList =(1,120,2,130,3,140…)
Please tell me how to join these two dynamic lists in one final list.
Thank You
Srini84
(Srinivas)
April 25, 2023, 7:50am
2
@siddhi.rani
FullList = list1.Union(list2).ToList()
Hope this may help you
Thanks,
Srini
Srini84
(Srinivas)
April 25, 2023, 7:51am
3
@siddhi.rani
FullList = list1.Union(list2).ToList()
FullList is a new List you can initialize
Thanks,
Srini
vkalra
(Vkalra)
April 25, 2023, 7:53am
4
You can iterate through one of the list and use the same index to add the items from both the list using the Append Item to List activity. So iterate through list 1 and keep adding item 1 from list 1 and item 1 from list 2 ( using the same index of 1) and so on…
1 Like
Srini84
(Srinivas)
April 25, 2023, 7:54am
5
@siddhi.rani
Also you can try as below
FullList = list1.Concat(list2).ToList()
The above is merging without checking for duplicates
FullList = list1.Union(list2).ToList()
Above will check the duplicates and make into one list
Hope these may help you
Thanks,
Srini
1 Like
@siddhi.rani
Declare the two lists that you want to combine
list1 = {“a”, “b”, “c”}
list2 = {“d”, “e”, “f”}
Use the Concat
method to combine the two lists into a new list
combinedList = list1.Concat(list2).ToList()
Yoichi
(Yoichi)
April 25, 2023, 7:59am
8
Hi,
if it’s unnecessary to take care result order, the following works.
list1.Concat(list2).ToList
If it’s necessary to alternate each items of list1 and list2, the following will help you.
Case of count of list1 is same count of list2
list1.Zip(list2,Function(s1,s2) {s1,s2}).SelectMany(Function(a) a).ToList
Case of count of list1 is more than count of list2
list1.SelectMany(Function(s,i) if(i<list2.Count,{s,list2(i)},{s})).ToList
Case of count of list1 is less than count of list2
list2.SelectMany(Function(s,i) if(i<list1.Count,{list1(i),s},{s})).ToList
Regards,
2 Likes
Thanks everyone for the help.
@Yoichi , your solution for 2nd Case to store alternate values, worked for me.
Thanks.
1 Like
system
(system)
Closed
April 28, 2023, 9:12am
10
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.