如何通过块"来观看在"中创建的对象?

时间:2017-11-15 08:16:10

标签: vb.net

我在" with block"中创建了一个没有命名的对象。

With Factory.CreateSomeObject()
    .SomeProp = someValue
    ...
End With

我的问题是:当调试器处于中断模式时,如何检查对象?

2 个答案:

答案 0 :(得分:2)

我认为这是不可能的,但您可以使用额外的一行:

Dim someObj As Object = Factory.CreateSomeObject()

With someObj
    .SomeProp = someValue
End With

使用此解决方案,您可以在第一行检查。

Some additional information on StackOverflow (similar question).

答案 1 :(得分:2)

当我在(7,8,9)块内的一行上设置断点时,从该函数返回的对象将显示在Locals窗口中。这是使用VS2015。此外,如果我右键单击With行上的功能名称并选择"添加监视",该对象将在监视窗口中显示。

我的代码:

With

当地人窗口:

enter image description here

观看窗口:

enter image description here

相关问题