是否有可能在调试时知道两个变量是否是同一个对象?
is it possible in debugging, to know if two variables are the same object?
我正在使用 Visual Studio 2019 社区,我有这个代码:
if(this != myOtherObject
&& anotherVariable != true)
{
//do something
}
这里的思路是我在if里面有各种条件。所以我想知道在调试时是否有某种方法可以知道它是第一个条件为真还是第二个等等。
如果没有,我认为唯一可行的方法是:
if(this != myOtherObject)
{
if(anotherVariable != true)
{
//do something
}
}
谢谢。
在您的条件中设置一个断点。
开始调试(F5)
突出this != myOtherObject
您的情况
右击 select Add Watch
现在您在手表中有了它的计算值 window。 (通常在底部弹出)
你可以使用Quick Watch
(Shift+F9) 如果你想要它的值一次。
我正在使用 Visual Studio 2019 社区,我有这个代码:
if(this != myOtherObject
&& anotherVariable != true)
{
//do something
}
这里的思路是我在if里面有各种条件。所以我想知道在调试时是否有某种方法可以知道它是第一个条件为真还是第二个等等。
如果没有,我认为唯一可行的方法是:
if(this != myOtherObject)
{
if(anotherVariable != true)
{
//do something
}
}
谢谢。
在您的条件中设置一个断点。
开始调试(F5)
突出
this != myOtherObject
您的情况右击 select
Add Watch
现在您在手表中有了它的计算值 window。 (通常在底部弹出)
你可以使用
Quick Watch
(Shift+F9) 如果你想要它的值一次。