gpt4 book ai didi

vb.net - 测试代码是否在 Debug模式下执行

转载 作者:行者123 更新时间:2023-12-03 23:02:05 26 4
gpt4 key购买 nike

我如何测试代码在 Debug模式下执行。

这是我想用伪代码做的事情

if not debugMode then
Do something()
end if

最佳答案

您可以使用 Debugger.IsAttached判断程序是否正在调试。

If Not Debugger.IsAttached Then
DoSomething()
End If

编辑如果你总是想跳过 DoSomething调试版本中的代码,无论是否使用调试器,都使用 conditional compilation#If ,像这样
#IF DEBUG Then
DoSomething()
#End If

关于vb.net - 测试代码是否在 Debug模式下执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1265581/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com