Reputation: 749
What exactly is the purpose of #define in C#?
I currently develop an application using the ShareFile .NET API from https://github.com/citrix/ShareFile-NET
However, the samples don't run because the function which I want to call is in this block:
#if Async
#endif
I know I can do
#define Async
at the top of the files, but do I have to do this for every file which has functions in this #if block? What's the purpose of this?
Upvotes: 0
Views: 283
Reputation: 151586
do I have to do this for every file?
No. You can pass symbols ("defines") to the compiler. Using Visual Studio, you can set that on the project level, at Project -> Properties -> Build -> Conditional compilation symbols
.
Using the command-line C# compiler (csc) you use the /define: flag, and when using other IDEs or compilers, see their documentation.
Upvotes: 7