0

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

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by Rashakil Fol
0

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

0

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

No, I could easily search in French.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.