Logo

Programming-Idioms

History of Idiom 218 > diff from v9 to v10

Edit summary for version 10 by programming-idioms.org:
[C#] Indeed!

Version 9

2020-01-19, 01:08:02

Version 10

2020-01-19, 12:22:31

Idiom #218 List intersection

Create list c containing all unique elements that are contained in both lists a and b.
c should not contain any duplicates, even if a and b do.
The order of c doesn't matter.

Idiom #218 List intersection

Create list c containing all unique elements that are contained in both lists a and b.
c should not contain any duplicates, even if a and b do.
The order of c doesn't matter.

Extra Keywords
intersect and conjunction
Extra Keywords
intersect and conjunction
Imports
using System.Linq;
using System.Collections.Generic;
Imports
using System.Linq;
using System.Collections.Generic;
Code
c = a.Union(b).ToList();
Code
c = a.Intersect(b).ToList();
Comments bubble
Shouldn't it be Intersect, not Union ?
Doc URL
https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable.intersect?view=netframework-4.8