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

  • Home
  • SEARCH
  • 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 6225607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:52:21+00:00 2026-05-24T08:52:21+00:00

Yes, I see the other topic: Visual Studio Debugger – Automatic Variable Assignment But

  • 0

Yes, I see the other topic: Visual Studio Debugger – Automatic Variable Assignment

But I needed a solution today, and found one before I see it, and I’m wondering if is there a better one out there?

My case:
I have a list of entities and I set up some policy related property based on a lot of factor. But it’s not implemented yet or simply I want to test the UI when the entity has a right and when not (change it as fast as possible to do the real job).

So I set up the entity as if it has the right, so I can test the UI with this. But I don’t want to break at every element in the list, and change the flag from true to false (to test the other case). I looked for a way to change a variable from debugger automatically. I came up with this solution:

  1. Set a breakpoint
  2. Setup a condition for it, which is a ‘fake’ one, but it gonna change the variable’s value
  3. run in debug mode
  4. if I need the case 1. I enable the breakpoint, if I need the other one, I disable the breakpoint

Simplified example:

namespace AutoVariable
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                new Program().Entrance();
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: {0}", e.Message);
            }
        }

        public void Entrance()
        {
            var entities = new List<Entity>
            {
                new Entity() { Name = "A" },
                new Entity() { Name = "B" },
                new Entity() { Name = "C" }
            };

            entities.ForEach(setRight);
            entities.ForEach(Console.WriteLine);
        }

        protected void setRight(Entity entity)
        {
            //not implemented
            bool hasRight = true;
            entity.HasRight = hasRight;
        }
    }

    class Entity
    {
        public bool HasRight { get; set; }

        public string Name { get; set; }

        public override string ToString()
        {
            return string.Format("{0} - {1}", Name, HasRight);
        }
    }
}

I set up a condition breakpoint to: entity.HasRight = hasRight;

with this condition: (hasRight = false)

so the hasRight will be false and the breakpoint never got a hit.

But it can be used in other cases also, for example in Jason Irwin’s post, you can use something like: (userName = "Jason").Length < 1

So my question that is it a good solution or I am missing something from the ‘native’ debugger toolset?

Thanks in advance!

negra

  • 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-05-24T08:52:22+00:00Added an answer on May 24, 2026 at 8:52 am

    You want to do an action using the debugger right? There’s a thing called Trace Points.

    It is explained here:
    http://weblogs.asp.net/scottgu/archive/2010/08/18/debugging-tips-with-visual-studio-2010.aspx
    and go down to “TracePoints – Custom Actions When Hitting a BreakPoint”

    Is that what you need?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all: yes, I read all the other threads on this topic. And
...Yes I've seen: Best Resources for Learning JavaFX? but it doesn't really answer the
Yes, There's More Than One Way To Do It but there must be a
Yes, I know you could use regular objects as associative arrays in JavaScript, but
If you see my other question , you'll know that I'm starting to try
I'm returning YES in my view controller's shouldAutorotateToInterfaceOrientation function, and I can see using
(see my answer below for solution - thanks for the feedback) It's probably something
I've come across a few other questions that describe a similar, but not identical
Almost all the examples I see are done with IB but I don't want
I realize there are other questions on SO regarding animations and progressbars, but they

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.