Is there a way to enter debug mode when a certain condition is met?
For example, let's say I would like to enter debug mode in the line on which i == 1it becomes true:
using System;
namespace ConditionalDebug
{
public class Program
{
public static void Main(string[] args)
{
var r = new Random();
var i = r.Next(2);
i += r.Next(2);
i += r.Next(2);
i += r.Next(2);
i += r.Next(2);
i = 1;
Console.WriteLine(i);
}
}
}
I know that you can set conditional breakpoints such as:

But, of course, I could not use this, since I would have to add a conditional breakpoint for each line in the code where the value of the condition could be changed, and this would be very random in a real application.
So, is there a way to globally set a condition i == 1so that the debugger breaks into a line on which the condition is satisfied?
Thank you for your help!
source
share