Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8061607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:23:37+00:00 2026-06-05T10:23:37+00:00

Is there a way to enter debug mode when a certain condition is met?

  • 0

Is there a way to enter debug mode when a certain condition is met?

For example let’s say I would want to enter debug mode on the line on which i == 1 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 it is possible to set conditional breakpoints like:

conditional breakpoint

But of course I couldn’t use that since I would have to add a conditional breakpoint for each line in the code where the condition value might get changed and that would get very messy in a real application.

So, is there a way to globally set the condition i == 1 so that the debugger will break on the line on which the condition is met?

Thanks for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:23:38+00:00Added an answer on June 5, 2026 at 10:23 am

    The short answer is ‘No’

    The long answer is ‘Not really, but kinda’. There are things you can do to get close to the behaviour you want.

    • You can use the Watch window and manually step through code and see it change.
    • You can find all references on the variable and isolate all the statements that can change your variable and place break points.
    • You could do the above, but use a wrapper function (or make it a Property) and only set the variable’s value through that function (or property setter) then you have a single point where you can set your conditional break-point to compare the old/new value.
    • You could put a break point on EVERY line and set the condition for all of them at once. You might be able to automate that by writing a VS Plug-in or Macro.
    • It’s beyond me – but I’m sure it is possible to do something amazingly complex and awesome like write your own debugger and implement your ‘Break whenever X Changes’.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to enter browser mode in a parallel foreach call? I've
Is there any way I can enter a particular filename - e.g. xyz.txt -
I am wondering if there is way to have the user enter a number
Is there any way to find which input character fails the regex pattern .
I want to change my command-line arguments and then debug my executable. With the
i want to know if there is a way to take size of a
Is there any way to disable the Press ENTER or type command to continue
Is there a way to enter a RewriteRule in the htaccess file to redirect
There a search service (PHP) which sends search query via POST. I would like
is there way how to get name ov event from Lambda expression like with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.