Where: Filters a sequence of values based on a predicate.
Select: Projects each element of a sequence into a new form.
Select: Projects each element of a sequence into a new form.
//Output: 1,2,3,4,5,6,7,8,9,10
var numbers = Enumerable.Range(1, 10);
//Output: 2,4,6,8,10
var even = numbers.Where(n => (n % 2) == 0).ToList();
//Output: false,true,false,true,false,....true
var evens = numbers.Select(n => (n % 2) == 0).ToList();
//Output: 1,2,3,4,5,6,...10
var lineNumbers = numbers.Select(i => i).ToList();
Reference: https://docs.microsoft.com/en-us/
0 comments:
Post a Comment