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 8499079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:34:21+00:00 2026-06-11T00:34:21+00:00

I do not understand what ‘conditional’ means for conditional breakpoints in Visual Studio. Maybe

  • 0

I do not understand what ‘conditional’ means for conditional breakpoints in Visual Studio. Maybe somebody can explain the following behavior?

When setting a conditional breakpoint (selecting ‘Is true’ in the popup) I expect it to behave in the same way as an expression within an “if” statement.

For example:

    int x = 1;
    // (1) Breakpoint with expression "x == 1" returns True and the debugger stops here
    // (2) Breakpoint with expression "x != 1" returns False and the debugger does not stop here
    // (3) Breakpoint with expression "x = 42" returns ?? and the debugger stops here (!!) and executes the assignment(!!)

Case (3) is obviously a typo. If I place expression (3) in an “if” statement

    if (x = 42) { /* ... */ }

the code would not compile.

The typo in (3) can be dangerous. I’ve placed a simple demo at GitHub demonstrating the issue.

When reading the MSDN docs on the subject this should not happen, right?

Thankful for any pointers.

Update: The code from GitHub

    using System;
    using System.Collections.Generic;
    using System.Linq;

    namespace ConsoleApplication1
    {
        /// <summary>
        /// Simple program showing that Visual Studio's conditional breakpoints do not have to return boolean results.
        /// 
        /// Tested with:
        /// - Visual Studio 2005
        /// - Visual Studio 2010
        /// </summary>
        public class Program
        {
            static void Main(string[] args)
            {
                var userService = new UserService();

                var userJon = new User {Id = 1, Name = "Jon Doe"};
                userService.SaveOrUpdateUser(userJon);

                var userSally = new User { Id = 2, Name = "Sally Sample" };
                userService.SaveOrUpdateUser(userSally);

                foreach (var user in userService.Users) {

                    // IMPORTANT: Add a conditional breakpoint on the next line with 'user.id = 1' (instead of 'user.id == 1' or 'user.id.Equals(1)'). See doc folder for screenshots.
                    int id = user.Id;

                    // ...some logic...

                    user.Id = id;

                    // ...some more logic...

                    userService.SaveOrUpdateUser(user);
                }

                // Show results of what just happened on command line
                Console.WriteLine("\n\nRESULTS==================================");
                foreach (var user in userService.Users) {
                    Console.WriteLine("User Id: " + user.Id);
                    Console.WriteLine("User Name: " + user.Name);
                }
                Console.WriteLine("\n\nEND RESULTS==================================");

                // Add a 'normal' breakpoint on the next line to read the console output
            }

        }

        internal class UserService
        {
            public UserService()
            {
                Users = new List<User>();
            }

            public List<User> Users { get; private set; }

            /// <summary>
            /// Imagine this method doing a database insert or update!
            /// </summary>
            public void SaveOrUpdateUser(User user)
            {
                Console.WriteLine("\tSaveOrUpdateUser...");
                Console.WriteLine("\tUser Id: " + user.Id);
                Console.WriteLine("\tUser Name: " + user.Name);

                User userAlreadyPresent = Users.FirstOrDefault(u => u.Name.Equals(user.Name)); // dummy find method

                if (userAlreadyPresent == null) {
                    Console.WriteLine("Adding new user");

                    Users.Add(user);    
                }
                else {
                    Console.WriteLine("\nUPDATING USER.......................");
                    Console.WriteLine("\tOld infos about user:");
                    Console.WriteLine("\tUser id: " + userAlreadyPresent.Id);
                    Console.WriteLine("\tUser name: " + userAlreadyPresent.Name);
                    Console.WriteLine("\tNew infos about user:");
                    Console.WriteLine("\tUser id: " + user.Id);
                    Console.WriteLine("\tUser name: " + user.Name);

                    userAlreadyPresent.Id = user.Id;
                }
            }
        }

        internal class User
        {
            public int Id { get; set; }
            public string Name { get; set; }
        }
    }
  • 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-11T00:34:23+00:00Added an answer on June 11, 2026 at 12:34 am

    The debugger works for debugging programs. Those programs may be written in any number of languages. F#, C#, VB, Assembly, C++, C, etc. Each of those languages has different semantics for it’s ability to evaluate an expression true or not. The debugger really doesn’t do anything very specific for a specific language (and in fact, probably doesn’t even know a particular bit of code it gets a breakpoint on was written in any particular language). It really just knows where things are in memory, and what they represent.

    Long story short, it doesn’t abide by the C# syntax when evaluating expressions for conditional breakpoints.

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

Sidebar

Related Questions

I do not understand how this code is compiling. Can somebody please explain what
I can not understand the following: WS-Security and https are presented as alternatives. The
Hello I can not understand a single moment. The following code in a simple
I can not understand the following code: Constructor<T>[] constructors = (Constructor<T>[]) clazz.getConstructors(); for(int i
I can not understand the following line: x => x.Id == _purchase.Centre.Id the code
I simply could not understand why the following code does not work. What could
I do not understand pointers. Where can I learn more about them?
I do not understand how following code works. Specifically, I do not understand using
I can not understand, why 'fatal' is here? And really all commits are pushed.
I do not understand how I can send an array with options to my

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.