如何在C#中使用#undef指令?
#undef指令允许您取消定义符号。以下是语法-
#undef SYMBOL
例如,
#undef One
与#if指令一起使用时,其计算结果为false。让我们看一个例子-
示例
#define One
#undef Two
using System;
namespace Demo {
class Program {
static void Main(string[] args) {
#if (One && TWO)
Console.WriteLine("Both are defined");
#elif (ONE && !TWO)
Console.WriteLine("ONE is defined and TWO is undefined");
#elif (!ONE && TWO)
Console.WriteLine("ONE is defined and TWO is undefined");
#else
Console.WriteLine("Both are undefined");
#endif
}
}
}输出结果
Both are undefined
热门推荐
10 生日油画棒祝福语简短
11 送水杯祝福语女生简短
12 给长辈敬祝福语简短
13 對好友毕业祝福语简短
14 哥哥祝福语简短霸气句子
15 毕业结婚祝福语简短精辟
16 宝宝新年祝福语大全简短
17 庆祝国家的祝福语简短
18 邻居女儿嫁人祝福语简短