C#编译器指令 [英] C# Compiler Directives

查看:154
本文介绍了C#编译器指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看一些C#代码,以及所遇到下面的语句:

I’m looking at some C# code, and have come across the following statement:

#if DEBUG
    // Do something here
#else
    // Do something else
#endif

我认为DEBUG将是一个地方定义如下:

I assumed that DEBUG would be a defined somewhere as follows:

#define DEBUG

但我无法找到这样的定义,虽然代码似乎表现得好像它被设置。正在调试一个特殊的情况,如果是这样,它是如何设置/取消?

But I’m unable to find such a definition, although the code seems to behave as though it were set. Is DEBUG a special case, and if so, how is it set / unset?

推荐答案

在该项目中,转到属性 - >建立。在一般情况下,你有一个选项有定义两个 DEBUG TRACE

On the project, go to Properties -> Build. Under general, you have an option there for defining both DEBUG and TRACE.

这篇关于C#编译器指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆