Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Need to use a compiler directive in C#

Posted on 2007-07-22
Medium Priority
Last Modified: 2013-12-17

Back in my C++ days I could include or exclude lines of code depending on the program I wanted to build.  I simply coded aditional variable thet I either commented out or utilized.

Can I do this in C#??

I use Visual Studio 2006 Version 8.0.

Please tell me if it's possible and how to implement it.

Question by:newbieweb
  • 2
LVL 30

Accepted Solution

anarki_jimbel earned 2000 total points
ID: 19543911
You can do what you want using preprocessor directives. Have a look http://www.dotnet-friends.com/articles/csharp/artincs12afebe2-59cf-45a4-9c55-2197153bc3ef.aspx.

Author Comment

ID: 19544028
At first glance, it looks like what I used to do in C++.  But now I am wondering if that's what I actually need.

I have a workiong program into which I integrated a web service.  But I am trying to run myprogram and a few other computers to process a large amount of data tonight.  But the web serice is not configured fro the extra machines and the guy who knows how to configure it won't be here until Monday.

I'd rather use a switch that I can load from a database to turn the web service functionality on or off.

I imagine I should not have any problem with this approach. Do you?

LVL 30

Expert Comment

ID: 19544233
Definitely. I'd go for this approach. Just set a flag to use some functionality or not. Should be easy, definitely easier than recompiling and deploying.

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question