Friday, August 1, 2008

Walrusize your LINQ!

This is a very short blog post... If selecting the same result data type as my element type within a collection I like to shorthand my code by using the Where() function instead of the more verbose LINQ syntax, which turns this:
var evenNumbers = from number in numbers
where number%2 == 0
select number;

Into this:
var evenNumbers = numbers.Where(
number => number%2 == 0 );

Am I being picky here?

No comments: