C#中#if DEBUG预处理器指令的用法是什么?我们什么时候用这个? [英] What is the usage of #if DEBUG pre-processor directive in C#? When must we use this?

查看:293
本文介绍了C#中#if DEBUG预处理器指令的用法是什么?我们什么时候用这个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#中使用 #if DEBUG 预处理器指令是什么?我们什么时候需要这样做?

What is the usage of #if DEBUG pre-processor directive in C#? When must we use this?

推荐答案

在调试模式下:

#if DEBUG
            System.Console.WriteLine("Debug version");
#endif
            System.Console.WriteLine("Output");

输出为

Debug version
Output

发布模式:

#if DEBUG
            System.Console.WriteLine("Debug version");
#endif
            System.Console.WriteLine("Output");

输出为

   Output

阅读:#if(C#参考)

用法:如果你有在调试模式下测试的值集合,而不是在释放模式下,您可以使用 #if DEBUG

Usage: If you have a set of values to be tested in the debug mode and not in the release mode you can use #if DEBUG

这篇关于C#中#if DEBUG预处理器指令的用法是什么?我们什么时候用这个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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