In C# one can define a preprocessor symbol like
#define DEBUG
How can I set a value, I wish to do something like this
#define VERSION = "X.Y.Z"
Is it possible ? If yes how can I get its value ?
No, you cannot assign a value to a conditional compilation symbol but you can use conditionally defined constants.
#define DEBUG
...
#if DEBUG
const string Version = "X.Y.Z";
#else
const string Version = "A.B.C";
#end if
As Victor said, C# doesn't have support for anything but boolean logic for #defines.
If you are looking for setting symbols from the project settings, use Resources (such as string resources) to do that.
If you are setting a version number of an application, the "Publish" tab of the project properties is one way of setting it. See this for a way to access it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With