Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use #undef directive in C#?
The #undef directive allows you to undefine a symbol. The following is the syntax −
#undef SYMBOL
For example,
#undef One
It evaluates to false when used along with #if directive. Let us see an example −
Example
#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
}
}
}
Output
Both are undefined
Advertisements