C#笔记整理(预处理命令)

C#预处理命令

  1. #define和#undef
    #define 它告诉编译器存在给定名称的符号
    #undef 它删除符号的定义
  2. #if #elif #else #endif
    这些指令告诉编译器是否编译某个代码块
#define DEBUG
#define BUG
static void Main(string[] args)
{

#if BUG
    Console.WriteLine("出BUG了");
#elif DEBUG
    Console.WriteLine("BUG解决了");
#else 
    Console.WriteLine("666666");
#endif
    Console.ReadKey();
}
#if =if
#elif =else if
#else =else
#endif 结束if
  1. #warning和#error
    #warning产生警告
    #error产生错误
  2. #regin和#endregin
#region 主函数
static void Main(string[] args)
{
    Console.WriteLine("666666");
    Console.ReadKey();
}
#endregion

会变为

主函数

这在大量的代码中会优化可读性

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值