Lists in programming are commonly used to store the collection of items such as String, Int, and so many data types.
We might sometimes need to find the common/uncommon items between the two Lists or two Arrays.
Let us see how to implement it!!!
Common Values
list_1.Intersect(list_2)
UnCommon Values
list_1.Except(list_2)
Note:
Replace list_1 and list_2 with your appropriate lists
Example
Implementation using UiPath :
Let us implement a workflow which takes a two sample lists and displays the common and uncommon values.
Step 1:
Drag “Assign” activity into the designer panel and initialize the list 1 with some sample data as shown below.
list_1 = new List(Of Int32)(New Int32(){1, 3, 4, 6, 7})
Step 2:
Drag another “Assign” activity into the designer panel and initialize the list 2 with some sample data as shown below.
list_2 = new List(Of Int32)(New Int32(){1, 2, 4, 5})
Step 3:
Drag “For Each” activity into the designer panel and supply the below-mentioned code into it and use “Message Box” to display the Common values between two lists
list_1.Intersect(list_2)
Step 4:
Drag “For Each” activity into the designer panel and supply the below-mentioned code into it and use “Message Box” to display the Uncommon values between two lists
list_1.Except(list_2)
Step 4:
Finally, run the project!!!
Click here to download the Source Code…
Hope it has helped you…