gpt4 book ai didi

c# - 在调试和发布设置 visual studio 中运行不同的代码

转载 作者:太空狗 更新时间:2023-10-29 21:05:56 24 4
gpt4 key购买 nike

在 C# 中是否可以在调试设置和发布设置中运行特定行代码。

if #debug

//run some lines of code

else

// run different lines of code

最佳答案

你可以这样做:

#if DEBUG
// Debug Code

#else
// Release Code

#endif

我在 WCF 服务中使用它来在调试时将其作为控制台应用程序运行,但在发布时作为 Windows 服务运行

喂,鲁伯特。

关于c# - 在调试和发布设置 visual studio 中运行不同的代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11154278/

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