
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
What is #define pre-processor directive in C#?
The #define pre-processor directive defines a sequence of characters, called symbol. It creates symbolic constants.
#define lets you define a symbol such that, by using the symbol as the expression passed to the #if directive, the expression evaluates to true.
Here is 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 } } }
- Related Articles
- What is a pre-processor directive in C#?
- What is a conditional pre-processor directive in C#?
- What are C# pre-processor directives?
- What are the Pre-processor Commands in C language?
- Explain the pre-processor directives in C language
- What is Superscalar Processor?
- What is CISC Processor?
- What is RISC Processor?
- What is a page directive in JSP?
- What is a include directive in JSP?
- What is a taglib directive in JSP?
- What is a @extend directive in SASS?
- Pre-increment (or pre-decrement) in C
- #pragma Directive in C/C++
- What Is Pre-existing cell

Advertisements