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

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

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

No, I could easily search in French.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.