如何在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
以上是 如何在C#中使用#undef指令? 的全部内容, 来源链接: utcz.com/z/331179.html