Lệnh #undef cho phép bạn hoàn tác ký hiệu. Sau đây là cú pháp -
#undef SYMBOL
Ví dụ,
#undef One
Nó đánh giá thành false khi được sử dụng cùng với chỉ thị #if. Hãy để chúng tôi xem một ví dụ -
Ví dụ
#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
}
}
} Đầu ra
Both are undefined