#define RELEASE
#undef DEBUG
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace YuChuLiQi
{
#pragma warning disable 169
class Program
{
//因为这里加了#pragma warning disable 169,所以字段未赋值的警告将看不见
static int noField;
static void Main(string[] args)
{
//要让这里编译else 不执行 这条语句,就要在开头加#undef DEBUG
//否则就加#define DEBUG
#if DEBUG
Console.WriteLine("执行");
#else
Console.WriteLine("不执行");
#endif
#if !RELEASE
Console.WriteLine("!Release");
// ! == && || !=运算是可以的
#elif !DEBUG
Console.WriteLine("!DEBUG");
#elif DEBUG
Console.WriteLine("DEBUG");
#endif
#if RELEASE
Console.WriteLine("Release");
#endif
#warning "警告"
Console.WriteLine("警告");
//#error "异常,不要编译"
Console.WriteLine("异常,不能编译通过");
#line 36 "core.cs"
Console.WriteLine("36");
Console.ReadKey();
}
}
}
原文:https://www.cnblogs.com/HelloQLQ/p/14998833.html