Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 14-11-2009
Member
 
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.
Reply With Quote
  #2  
Old 14-11-2009
Member
 
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
Reply With Quote
  #3  
Old 14-11-2009
Member
 
Join Date: May 2008
Posts: 2,293
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"); 
  } 
}
Reply With Quote
  #4  
Old 14-11-2009
Member
 
Join Date: May 2008
Posts: 2,383
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.
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Explain #define preprocessor directive"
Thread Thread Starter Forum Replies Last Post
what is the use of iostream directive? Diellza Software Development 4 08-01-2011 12:46 AM
Explain how to define function outside the class in C++? Palnila Software Development 4 29-12-2010 03:11 AM
How can I use the pragma directive in C? Tailor Software Development 3 21-01-2010 08:39 AM
What is the meaning of Hypertext PreProcessor in PHP Gefry Software Development 3 10-09-2009 10:28 AM
PHP (Hypertext Preprocessor): Installation and Configuration - Manual Pyrotechnic Guides & Tutorials 5 24-03-2009 10:45 PM


All times are GMT +5.5. The time now is 12:10 AM.