Share via


Conditional Compilation Symbols?

Question

Sunday, August 29, 2010 8:07 AM

Hi,

I want to know more about the conditional compilation symbols in a class library.

Regards,

ap.

All replies (5)

Wednesday, September 1, 2010 9:57 PM ✅Answered

I want to define my own compilation constants for generating custom code. How can I do that?

 

Hi,

Right click the project (The Class Library is a project) and click Properties to open the properties window. Then click the Build tab, input symbols in the “Conditional compilation symbols:” textbox. Use comma to separate each symbol (e.g. “MySymbol1,MySymbol2”). Then use them in this way.

#if MySymbol1
    // You code
#endif

Thursday, September 2, 2010 2:57 AM ✅Answered

public Void MyFunction()
{
   CallA();
   CallB();
}

// This code will only execute when you have debug build executing
[Conditional("Debug")]
private void CallA()
{
   //. CODE
}

/// ALSO can use some thing like
#IfDef DEBUG
  // CODE
#endif

Regards,

Soumen


Sunday, August 29, 2010 9:03 AM

Hi,

Please refer following

http://msdn.microsoft.com/en-us/library/swfss70d%28VS.90%29.aspx

http://geekswithblogs.net/elroydsilva/archive/2008/10/31/conditional-compilation-in-c.aspx

hope this helps


Wednesday, September 1, 2010 2:50 AM

Hi,

  Visit these links hope it helps you.

 http://stackoverflow.com/questions/1981212/conditional-compilation-symbols-not-being-defined

 http://stackoverflow.com/questions/1221343/how-to-define-conditional-compilation-symbols-in-separate-file-not-csproj-or-ap

 http://bytes.com/topic/asp-net/answers/824308-import-namespace-using-conditional-compilation-symbols

                   PLEASE MARK IT AS ANSWER IF IT SOLVES YOUR QUERY


Wednesday, September 1, 2010 4:03 AM

Hi,

Thanks for your message. I want to define my own compilation constants for generating custom code. How can I do that?

Regards,

ap.