using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 控制台
{
class Program
{
static void Main(string[] args)
{
#if RELEASE
Console.WriteLine("aaaaaaaa");
#elif DEBUG
Console.WriteLine("bbbbbbbb");
#endif
Console.ReadKey();
}
}
}我解决方案配置改成了Release,可是为什么全部都成灰色了呢?没有输出
不是有一个如果是Release就输出aaaaaaaa的吗?
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 控制台
{
class Program
{
static void Main(string[] args)
{
#if RELEASE
Console.WriteLine("aaaaaaaa");
#elif DEBUG
Console.WriteLine("bbbbbbbb");
#endif
Console.ReadKey();
}
}
}我解决方案配置改成了Release,可是为什么全部都成灰色了呢?没有输出
不是有一个如果是Release就输出aaaaaaaa的吗?
不是#If DEBUG表示“如果是debug”模式,而是debug配置时IDE自动给你定义了一个DEBUG常量。
但是Release配置时是没有定义什么RELEASE常量的,而是去掉了DEBUG常量的定义
当然这些你可以手动改
你需要自己在项目属性里设置。
那代码中,实际上基本上是用不着RELEASE这个符号的哦,是吧
那...那RELEASE不是一个符号吗?VS没有定义它,它又删除DEBUG定义?这是啥符号啊?
一两句也说不清楚,参考
http://msdn.microsoft.com/zh-cn/library/yt3yck0x.aspx只是vs会自动为debug模式加上/define DEBUG. 而不会为Release版本加上/define RELEASE。但是你可以自己#define RELEASE或者为compiler加上/debug RELEASE