linq.First

Gets the first element in the array. An exception is thrown if the array contains zero elements.

Overloads

  • Object First ()
  • Object First (condition)

Object First ()

Gets the first element in the array
var myArray = [1, 2, 3, 4];
//Returns 1
myArray.First();

Object First (condition)

Gets the first element in the array where the specified condition is met

Example

var myArray = [1,3,4,5];
//Returns 4
myArray.First("x => x % 2 == 0");

//Throws an exception
myArray.First("x => x == 42");

Last edited Sep 24, 2011 at 6:34 AM by mlorbetske, version 4

Comments

No comments yet.