In this post I will share how easy we can debug LINQ and Lambda expressions in Visual Studio 2015. Sometimes, it is difficult to see larger list in debugging mode. With this feature of VS 2015 we can filter list using LINQ or Lambda expression using Immediate or Watch windows.
Let’s take a quick example of a console application that calls up a method named GetPersons that returns the list of persons.
Below is the class that call GetPersons method which returns a list of 4 persons
Now let’s put a break point at the end of Main method
You can see that GetPersons() returned the list which you can even see it in the Immediate or Watch windows in earlier versions of Visual Studio as well. But if you want to filter records using some LINQ or Lambda expression, it is not possible in previous versions.
Below is the snap shot taken from VS 2013 that shows this error “Expression cannot contain lambda expressions”
If you run the same expression in Visual Studio 2015. You will see the result like this
You can also use Immediate Window to filter records as below
Hope this helps!