Debugging lambda expressions
The ability to debug lambda expressions has been around since Visual Studio 2015. This is a fantastic addition to the features of our favorite IDE. It allows us to check the results of a lambda expression on the fly and modify the expression to test different scenarios.
Getting ready
We will create a very basic lambda expression and change it in the Watch
window to produce a different value.
How to do it...
- Create a console application and add a class called
LambdaExample
to the console application. Add a property to this class calledFavThings
:
public class LambdaExample { public string FavThings { get; set; } }
- In the console application, create a
List<LambdaExample>
object and add a few of your favorite things to this list:
List<LambdaExample> MyFavoriteThings = new List<LambdaExample>(); LambdaExample thing1 = new LambdaExample(); thing1.FavThings = "Ice-cream"; MyFavoriteThings...