#define, #if, and #endif preprocessor directives : Preprocessor Directives : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Preprocessor Directives »

 

#define, #if, and #endif preprocessor directives









    

/*
Mastering Visual C# .NET
by Jason Price, Mike Gunderloy

Publisher: Sybex;
ISBN: 0782129110
*/
/*
  Example4_16.cs illustrates the use of the
  #define, #if, and #endif preprocessor directives
*/

#define DEBUG

public class Example4_16
{

  public static void Main()
  {

    int total = 0;
    int counter = 0;

    myLabel:
    counter++;
    total += counter;
    System.Console.WriteLine("counter = " + counter);
    if (counter < 5)
    {
#if DEBUG
      System.Console.WriteLine("goto myLabel");
#endif
      goto myLabel;
    }

    System.Console.WriteLine("total = " + total);

  }

}


           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Preprocessor Directives