.

C# Preprocessor Directives Assignment Help

PREPROCESSOR DIRECTIVES

  • It’s a directive which provides step by step procedure to preprocess the information to the compiler prior to the actual compilation starts.
  • All pre-processors begin with # symbol
  • A pre-processor directive does not end with a semicolon (;).
  • C# language compiler does not have a its separate preprocessor
  • In C# the preprocessor directives are used to help in provisional compilation and they are not used to create macros.
  • The only instruction on a line is a pre-processor directive

C# Preprocessor Directives Assignment Help By Online Tutoring and Guided Sessions from assignmenthippo.com


 The lists of preprocessor directives in C#

#define

#undef

#if

#else

#elif

#elif

#line

#error

#warning

#region

#endregion

Example: The #define Pre-processor

 

The #define pre-processor directive creates symbolic literals.

Syntax

#define symbol

The following program demonstrates the usage of #define directives

#define P

using System;

namespace Preprocessor

 {

classNameProgram

 {

static void Main(string[] args)

{

#if (P)

Console.WriteLine("P is defined");

#else

Console.WriteLine("P is not defined");

#endif

Console.ReadKey();

}

}

}

Output: P is defined

.