#define PI
#define DEBUG
#define VC_V10
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
//预处理指令
//知道编译器在实际编译开始之前对信息进行预处理
//预处理器指令 描述
/*
* #define 它用于定义一系列成为符号的字符。
* #undef 它用于取消定义符号。
* #if 它用于测试符号是否为真。
* #else 它用于创建符合条件指令,与#if一起使用。
* #elif 它用于创建复合条件指令。
* #line 它可以让你修改编译器的行数以及(可选地)输出错误和警告的文件名。
* #error 它允许从代码的指定位置生成一个错误。
* #warning 它允许从代码的指定位置生成一级警告。
* #region 它可以让你在使用Visual Studio Code Editor的大纲特性时,指定一个可以展开或折叠的代码块。
* #noregion 它标识着#region块的结束。
*/
#if (PI)
Console.WriteLine("PI is defined.");
#else
Console.WriteLine("PI is not defined.");
#endif
#if (DEBUG && !VC_V10)
Console.WriteLine("DEBUG is defined.");
#elif (!DEBUG && VC_V10)
Console.WriteLine("VC_V10 is defined.");
#elif (DEBUG && VC_V10)
Console.WriteLine("DEBUG and VC_V10 are defined.");
#else
Console.WriteLine("DEBUG and VC_V10 are not defined.");
#endif
#if DEBUG && RELEASE
#error "You've defined DEBUG and RELEASE simultaneously!"
#endif
#warning "Don't forget to remove this line before the boss tests the code!"
Console.WriteLine("*I hate this job.*");
#region Member Field Declarations
int x;
double d;
#endregion
Console.ReadKey();
}
}
}