KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
When writing a LINQ query with multiple "and" conditions, I can write a single where clause containing && or I can write multiple where clauses, one for each condition: static void Main() { var ints = new List<int>(Enumerable.Range(-10, 20)); var positiveEvensA = from i in ints where (i > 0) && ((i % 2) == 0) select i; var positiveEvensB = from i in ints where i > 0 where (i % 2) == 0 select i; System.Diagnostics.Debug.Assert(positiveEvensA.Count() == positiveEvensB.Count()); } Is there any difference other than personal preference or coding style (long lines, readability, etc.) between positiveEvensA and positiveEvensB ? One possible difference that comes to mind is that different LINQ providers may be able to better cope with multiple where s rather than a more complex expression; is this true?
Tags (comma-separated)
Save Edits
Cancel