linq.Intersect

Produces the set intersection of two sequences by using the default equality comparer to compare values

Overloads

  • Array Intersect (array)
  • Array Intersect (array, equalityComparer)

Array Intersect (array)

Produces the set intersection of two sequences by using the default equality comparer to compare values

Example

var myArray = [1,3,4,5];
var myArray2 = [1,4,7];
//Returns [1,4]
myArray.Intersect(myArray2);

Array Intersect (array, equalityComparer)

Produces the set intersection of two sequences by using the specified equality comparer to compare values

Example

var myArray = [{x:1},{x:3},{x:4},{x:5}];
var myArray2 = [1,4,7];
//Returns [{x:1},{x:4}]
//NOTE: The elements from "myArray" are passed as the second argument to the equality comparer
//          and elements from "myArray2" are passed in as the first
myArray.Intersect(myArray2, "(a, b) => a == b.x");

Last edited Sep 24, 2011 at 2:30 AM by mlorbetske, version 3

Comments

No comments yet.