Support for debugging lambda expressions in Visual Studio 2015

Microsoft Visual Studio 2015 introduces many new features. Some features are described below using the diagram and I introduce one of them, support of debugging lambda expressions in Visual Studio 2015.

lambda expressions

The term or word lambda expression is a programming concept. It came into existence with C# 3.0. Lambda expressions are used for anonymous methods. With a lambda expression we use an anonymous method very easily. When we compile our code then the lambda expression will be converted into the anonymous method. lambda expressions use the (=>) operator.
For example we write the lambda expression like y => (a+b)+(a*B).

Here the right hand side is known as the lambda input and the right hand side is known as the lambda expression and (=>) known as the lambda operator.

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. class lambda
  7. {
  8. //this is a delegate for represent a anonymous method/class
  9. //delegate is a keyword delegate1 is delegate name
  10. delegate float deldelegate1(float a, float b);
  11. static void Main(string[] ags)//entry point of our program
  12. {
  13. //anonymous method using expression lambda
  14. deldelegate1 obj1 = (a, b) => a + b;
  15. //anonymous method using statement lambda
  16. deldelegate1 obj2 = (a, b) => { return a * b; };
  17. float result1 = obj1(2,3);
  18. float result2 = obj2(2,5);
  19. Console.WriteLine(result1);
  20. Console.WriteLine(result2);
  21. Console.Read();
  22. }
  23. }


Debugging lambda expressions

Now we discuss how we do something with an expression in Visual Studio 2015 preview.

This is the new feature in Visual Studio 2015 preview that we can debug lambda expressions. Here I explain how to debug a lambda expression in Visual Studio 2015 preview so please use the following procedure.

Breakpoint performance during debugging

We can make many types of events in the Conditions section or in the Action section. When you run the given code you can find them easily. When you run the program you get the output rupees 6300. You can also check it at the breakpoint.





You can add 2 actions during the execution of our breakpoints in Visual Studio 2015.

Output



Summary

Finally we can say that Visual Studio 2015 provides good features for debugging a lambda expression or simple program using two types of breakpoints, one is conditional and the other is Action. These two breakpoints types provide different types of features to debug a program. So they make Microsoft Visual Studio 2015 more powerful.