Álvaro García
Álvaro García

Reputation: 19356

is it possible in debugging, to know if two variables are the same object?

I am using Visual Studio 2019 community and I have this code:

if(this != myOtherObject
   && anotherVariable != true)
{
     //do something
}

Here the idea is that I have various conditions in the if. So i would like to know if there is some way in debugging to know if it is the first condition true or the second and so on.

If not, the only way that I think it is possible is in this way:

if(this != myOtherObject)
{
    if(anotherVariable != true)
    {
        //do something
    }
}

thanks.

Upvotes: 0

Views: 61

Answers (1)

MrMoeinM
MrMoeinM

Reputation: 2378

  • Put a breakpoint in your condition.

  • Start Debugging (F5)

  • Highlight this != myOtherObject in your condition

  • Right-click and select Add Watch

  • Now you have its calculated value in the Watch window. (Usually pops up at the bottom)

  • You can use Quick Watch (Shift+F9) if you want its value once.

Upvotes: 2

Related Questions