#ifndef _DEBUG等效... [英] #ifndef _DEBUG equivalent...
问题描述
在C ++中你可以使用以下内容:
#ifndef _DEBUG
//这里的代码只能在调试模式下运行
#endif
您可以在其中设置不同的代码以包含在不同的版本中。有用
只有在
Debug中编译项目时才有调试的日志系统,但是想要在Release中关闭它。
这可能用c#.net吗? (VS.net 2003)
谢谢!
Dan。
In C++ you can use the following:
#ifndef _DEBUG
// code here only runs in debug mode
#endif
where you can set different code to be included in different builds. Useful
for having a logging system for debugging only when compiling the project in
Debug, but wanting to turn it off in Release.
It this possible with c#.net? (VS.net 2003)
Thanks!
Dan.
推荐答案
#if DEBUG
//这里的代码只能在调试模式下运行
#endif
" Daniel低音及QUOT; <我真的@厌恶垃圾邮件>在消息中写道
news:eM ************** @ tk2msftngp13.phx.gbl ...
#if DEBUG
// code here only runs in debug mode
#endif
"Daniel Bass" <I''m really @ sick of spam> wrote in message
news:eM**************@tk2msftngp13.phx.gbl...
在C ++中你可以使用以下内容:
#ifndef _DEBUG
//这里的代码只能在调试模式下运行
#endif
其中您可以设置不同的代码以包含在不同的版本中。
只有在Debug中编译项目
时才有用于调试的日志系统,但想要在Release中关闭它。
这可能用c#.net吗? (VS.net 2003)
谢谢!
Dan。
In C++ you can use the following:
#ifndef _DEBUG
// code here only runs in debug mode
#endif
where you can set different code to be included in different builds. Useful for having a logging system for debugging only when compiling the project in Debug, but wanting to turn it off in Release.
It this possible with c#.net? (VS.net 2003)
Thanks!
Dan.
<" Daniel低音及QUOT; <我真的@厌恶垃圾邮件>>写道:
<"Daniel Bass" <I''m really @ sick of spam>> wrote:
在C ++中你可以使用以下内容:
#ifndef _DEBUG
//这里的代码只能在调试模式下运行
#endif
我想你的意思是:
#ifdef _DEBUG
那里。
你也可以用C#做到这一点:
#if DEBUG
......
#endif
您可以在其中设置不同的代码以包含在不同的版本中。有用的
只有在
Debug中编译项目时才有调试的日志系统,但想要在Release中关闭它。
In C++ you can use the following:
#ifndef _DEBUG
// code here only runs in debug mode
#endif
I think you meant:
#ifdef _DEBUG
there.
You can do that with C# too:
#if DEBUG
....
#endif
where you can set different code to be included in different builds. Useful
for having a logging system for debugging only when compiling the project in
Debug, but wanting to turn it off in Release.
For在你正在调用的
方法中使用属性实际上更容易一些 - 查看Trace类的例子。
-
Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet
如果回复小组,请不要给我发邮件
For that kind of thing it''s actually easier to use an attribute on the
method you''re calling - look at the Trace class for an example.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
另外,如果你使用Debug语句Debug.WriteLine,Debug。*,c#
和vb.net编译器会自动忽略发布中的这些陈述
版本。
-
Eric Newton
C#/ ASP应用程序开发人员
http://ensoft-software.com/
er ** @ cc.ensoft-software.com [删除第一个CC。]
" Jon Skeet [C#MVP]" < SK *** @ pobox.com>在消息中写道
新闻:MP ************************ @ msnews.microsoft.c om ...
Also, if you use the Debug statements "Debug.WriteLine", "Debug.*", the c#
and vb.net compilers automatically ignore these statements in release
builds.
--
Eric Newton
C#/ASP Application Developer
http://ensoft-software.com/
er**@cc.ensoft-software.com [remove the first "CC."]
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
<" Daniel Bass" <我真的@厌恶垃圾邮件>>写道:
<"Daniel Bass" <I''m really @ sick of spam>> wrote:
在C ++中你可以使用以下内容:
#ifndef _DEBUG
//这里的代码只能在调试模式下运行
#endif
In C++ you can use the following:
#ifndef _DEBUG
// code here only runs in debug mode
#endif
我认为你的意思是:
#ifdef _DEBUG
那里。
你也可以用C#做到这一点:
#if DEBUG
...
#endif
I think you meant:
#ifdef _DEBUG
there.
You can do that with C# too:
#if DEBUG
...
#endif
你可以在哪里设置不同的代码包含在不同的版本中。
仅用于在Debug中编译
项目时需要调试的日志系统,但想要在Release中关闭它。
where you can set different code to be included in different builds. Useful for having a logging system for debugging only when compiling the project in Debug, but wanting to turn it off in Release.
对于那种事情它实际上更容易在你调用的
方法上使用一个属性 - 查看Trace类的例子。
-
Jon Skeet - < ; sk *** @ pobox.com>
http://www.pobox .com / ~siget
如果回复小组,请不要给我发邮件
For that kind of thing it''s actually easier to use an attribute on the
method you''re calling - look at the Trace class for an example.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
这篇关于#ifndef _DEBUG等效...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!