9th April 2014

How Linq to Objects Queries Work

If you have ever tried to step through a Linq to Objects query in the debugger, you may have been mildly surprised at the results. It may have seemed as if the program had a mind of its own and ran certain expressions when it wanted to and not when it was supposed to. Be assured, it is doing the right thing and the order of evaluation is giving you a glimpse of what actually happens when a query is evaluated. Consider this query: using System; using System.Linq; class Program { static void Main() { var foo = new[] { […]