Take
The Take
method takes an integer as a parameter. This parameter will specify how many items to take from an array or list.
Basic example
The example below uses Take(3)
. This means it will only take the first 3
items and return a new list.
Live example: https://dotnetfiddle.net/HeiGWI
var scores = new[] { 87, 56, 33, 20, 11 };
var newScores = scores.Take(3);
//output: 87, 56, 33