How to find Common and Uncommon Values between 2 Lists in UiPath

Lists in used to store the collection of items such as String, Int and so many other data types.

Let us see how to implement it!!!

Common Values

list_1.Intersect(list_2)

UnCommon Values

list_1.Except(list_2)

# 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})

image

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})

image

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)

image

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)

image

Step 4:
Finally, run the project!!!

I hope you liked the article.

Happy Automation!!!