Results 1 to 4 of 4

Thread: Explain #define preprocessor directive

  1. #1
    Join Date
    Nov 2009
    Posts
    61

    Explain #define preprocessor directive

    I am covering a topic called Preprocessor Directive in Csharp. I have learnt the #if preprocessor directive, but I am not able to grasp what is the #define preprocessor directive. How is it actually used? I have been using Java for along time but I am new to Csharp. I am totally confused over this topic. Reply fast.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Explain #define preprocessor directive

    There is a huge similarity between C preprocessor and C sharp preprocessor. Infact the C sharp preprocessor are said to be derived from C programming language. the #define will allow you to define a symbol to be used as the #if directive's expression.
    Syntax:
    Code:
    #define symbol

  3. #3
    Join Date
    May 2008
    Posts
    2,297

    Re: Explain #define preprocessor directive

    I am also a new programmer to Csharp programming. I find this very interesting and easy to learn and develop application for .NET Framework. This example will illustrate the use of #define preprocessor directive in C sharp.

    Code:
    #define Temp 
     
    using System; 
     
    public class A
    { 
      public static void Main()
      { 
        #if Temp 
        Console.WriteLine("From #IF"); 
        #endif 
        Console.WriteLine()
        Console.WriteLine("Outside #IF"); 
      } 
    }

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: Explain #define preprocessor directive

    C# preprocessor directives have alot of resemblence to the C preprocessor directives. The #define directive lets the programmer to define symbols which control the compilation of the C# code. #define preprocessor directive of C sharp defines a symbol whereas the #undef preprocessor directive of C sharp undefines a symbol.

Similar Threads

  1. what is the use of iostream directive?
    By Diellza in forum Software Development
    Replies: 4
    Last Post: 08-01-2011, 12:46 AM
  2. Explain how to define function outside the class in C++?
    By Palnila in forum Software Development
    Replies: 4
    Last Post: 29-12-2010, 03:11 AM
  3. How can I use the pragma directive in C?
    By Tailor in forum Software Development
    Replies: 3
    Last Post: 21-01-2010, 08:39 AM
  4. What is the meaning of Hypertext PreProcessor in PHP
    By Gefry in forum Software Development
    Replies: 3
    Last Post: 10-09-2009, 10:28 AM
  5. Replies: 5
    Last Post: 24-03-2009, 10:45 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,517,437.12785 seconds with 17 queries