---
title: "Preprocessor Directives in C#"  
description: "Preprocessor directives are instruction or command. This is the simplymacro (The C preprocessor is a macro processor that is usedautomatically by the"  
author: "Amit Singh"  
published: 2011-01-14  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/96/preprocessor-directives-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Preprocessor Directives in C#

Preprocessor [directives](https://www.mindstick.com/blog/44/directives-in-asp-dot-net) are instruction or command. This is the simplymacro (The C preprocessor is a macro [processor](https://www.mindstick.com/news/2830/qualcomm-s-snapdragon-8-gen-3-processor-might-arrive-earlier-than-expected) that is usedautomatically by the C [compiler](https://www.mindstick.com/articles/27/just-in-time-compiler) to [transform your](https://yourviews.mindstick.com/story/4362/dry-fruits-to-transform-your-daily-diet) [program](https://www.mindstick.com/blog/12337/scaling-up-your-mentorship-program) before actualcompilation. It is called a macro processor because it allows you to definemacros) term which is the part of c, andc++ then these [concept](https://www.mindstick.com/blog/79/routing-concept-in-dot-net) adopt in c#. C# contains set of directives which tellsthe complier to evaluate it.

*“A preprocessordirective must be the only instruction on a line. “*

There are followingset of directives in c#:

· #if

· #else

· #elif

· #endif

· #[define](https://yourviews.mindstick.com/audio/1110/lifestyles-choices-that-define-our-lives)

· #undef

· #warning

· #error

· #line

· #region

· #endregion

##### Forexample

```
#define india //defineddirective in start of the programusing System;using System.Collections.Generic;using System.Linq;using System.Text; namespace ConsoleApplication1{    class Program    {        static void Main(string[] args)        {#if (india)          Console.WriteLine("Definethe india");#else         Console.WriteLine("Not defined the india");#endif          Console.ReadLine();        }    }} 
```

\

##### Output:

\

Define the [india](https://www.mindstick.com/articles/12769/why-consider-international-business-mba-in-india)\
Note: directives is always defined at thestart of the program.

---

Original Source: https://www.mindstick.com/blog/96/preprocessor-directives-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
