linq.Union

Produces the set union of two arrays by using the default equality comparer.

Overloads

  • Array Union (array)
  • Array Union (array, comparator)

Array Union (array)

Produces the set union of two sequences by using the default equality comparer
var myArray = [1, 2, 3, 4];
var mySecondArray = [2, 5];
//Returns [1, 2, 3, 4, 5]
myArray.Union(mySecondArray);

Array Union (array, comparator)

Produces the set union of two sequences by using the specified equality comparer
var myArray = [{x: 1}, {x: 2}, {x: 3}, {x: 4}];
var mySecondArray = [{x: 2}, {x: 5}];
//Returns [{x: 1}, {x: 2}, {x: 3}, {x: 4}, {x: 5}]
myArray.Union(mySecondArray, "(a, b) => a.x == b.x");

Last edited Sep 24, 2011 at 7:46 AM by mlorbetske, version 1

Comments

No comments yet.