Debugging Lambda expression is one of the coolest feature of Visual Studio 2015 and that’s bring lot of productivity among developers during debugging and release lot of pain. Using lambda expression is pretty often in code, mostly when we writes lots of LINQ statements. Priory to Visual Studio 2015, there was no direct and easy way, where we can debug, or inspect any lambda expression.
Now, Visual Studio 2015, support debug and run lambda express in Watch Windows, Immediate Window and in DataTips as well .
Let’s take a look at the following class Student
Following code block use the Student Class, and display a list of Students having marks greater than 40.
Now, consider you want to debug, manipulate some values with students. Let’s have a look how to do it.
Immediate Window – Run, Debug & Inspect Lambda Expression
This is just awesome ! You will start getting all LINQ expression, extension method and write you own query too.
You can simply execute or debug the Lambda expression.
This save a lot of time and gave a lot of flexibility to developers.
Watch Window – Run, Debug & Inspect Lambda Expression
Watch windows is one of most commonly used debugging tool with Visual Studio. We generally used to explore the objects, values, properties and other nested objects as a tree structure. We can do lot of stuff using Watch Window. Now we can do, debugging of Lambda Expression.
Must Read : Watch Window Tips and Tricks
Select the LINQ Expression and Click on Add To Watch
Now, Explore Your Data coming out of LINQ / Lambda
You can even write fresh statement.
And Of course, same things you can do it for Quick Watch Too.
DataTips – Run, Debug & Inspect Lambda Expression
DataTips is an advanced tooltip message that can be used for inspecting the objects or variables while debugging the application with in Visual Studio. Along with Watch Window and Immediate Window, DataTips also support debugging of Lambda Expression.
Step 1 : Add a DataTips during Debugging
Step 2: Right Click on the DataTips and select “Add Expression” from the context menu.
Must Read : Adding New Expression in Visual Studio DataTips
Step 3 : Run and Execute Lambda Expression.
Hope this helps !
Pingback: Dew Drop – July 27, 2015 (#2061) | Morning Dew
Pingback: 10 New features of Visual Studio 2015 that you should know | Abhijit's World of .NET
Pingback: .NET Tips and Tricks from Daily .NET Tips – ( Visual Studio 2015, Windows Universal App Development, Microsoft Band, Xamarin ) – July 2015 Links | Abhijit's World of .NET
Pingback: Visual Studio – Developer Top Ten for August 4th, 2015 - Dmitry Lyalin