linq.Contains

Determines whether an array contains a specific element

Overloads

  • bool Contains (element)
  • bool Contains (element, equalityComparer)

bool Contains (element)

Returns true if element is found in the array

Example

var myArray = [1,3,5];
//Returns true
myArray.Contains(3);

bool Contains (element, equalityComparer)

Returns true if, when equalityComparer is evaluated on any one element in the array (as the first parameter) and element (as the second), the result is true.

Example

var myArray = [{Field:1}, {Field:2}, {Field:3}];

//Lambda form:
myArray.Contains(3, "(a, b) => a.Field == b");

//Function form
myArray.Contains(3, function(a, b) { return a.Field == b; });

Last edited Sep 23, 2011 at 4:57 AM by mlorbetske, version 1

Comments

No comments yet.