First find

suggest change
var numbers = new[] {1,2,3,4,5};

var firstNumber = numbers.First();
Console.WriteLine(firstNumber); //1

var firstEvenNumber = numbers.First(n => (n & 1) == 0);
Console.WriteLine(firstEvenNumber); //2

The following throws InvalidOperationException with message “Sequence contains no matching element”:

var firstNegativeNumber = numbers.First(n => n < 0);

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents