954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to set defined preprocessor value?

i need a third way to do it at compile time without command line but using visual studio editor.


at : http://www.csharphelp.com/archives/archive36.html

two ways are as follows:

1.Define in your C# program
2.Define them at command line on compile time
Here is example for first way:
Example:

#define TEST
using System;
public class MyClass 
{		
   public static void Main() 
   {
      #if (TEST)
         Console.WriteLine("TEST is defined");      
      #else
         Console.WriteLine("TEST is not defined");
      #endif
   }
}


Output
TEST is defined
In other way you can define it at command line. So program will be like this:
Example

using System;
public class MyClass 
{		
   public static void Main() 
   {
      #if (TEST)
         Console.WriteLine("TEST is defined");      
      #else
         Console.WriteLine("TEST is not defined");
      #endif
   }
}


At compile time user can define as below:
csc /define:TEST MyClass.java
Output
TEST is defined
And if the command line will be like:
csc MyClass.java
Output
TEST is not defined


thanks

serkan sendur
Postaholic
Banned
2,062 posts since Jan 2008
Reputation Points: 854
Solved Threads: 127
 
Rashakil Fol
Super Senior Demiposter
Team Colleague
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
 

Thanks, you are very good at searching and locating information, maybe because your first language is english.

serkan sendur
Postaholic
Banned
2,062 posts since Jan 2008
Reputation Points: 854
Solved Threads: 127
 
Thanks, you are very good at searching and locating information, maybe because your first language is english.

No, I could easily search in French.

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You