ncite ncite - 1 year ago 101
C# Question

Does C# allow Preprocessor Directive for different Solutions

We have Preprocessor Directives in Visual Studio for c#, for example:

#define CONDITION1


But what should I do if I have a library and want it to compile differently to different solution?

For example, I want to #define CONDITION1 in solution1, and #define CONDITION2 in solution2, what should I do?

Answer Source

Unless you're distributing the raw C# project to be included in several solutions, you're out of luck. If you're going that route, you'd use them the same as any other #define.

Most libraries are distributed as pre-compiled source which means that all of the #defines would've been handled already. You'd have to fall back to configuration values (which is exactly how behaviors like this should be handled).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download