Currently in my code I have this if-statement:
if (System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Major > 0)
{
//Stuff that will execute when we get out of beta
}
Since it is possible to predict the outcome of this statement at compile time I wonder, just out of curiosity, if there is a way to replace it with something like
#if MAJOR_VERION > 0
//Do stuff
#endif
Additionally, if this is possible, is it good or bad .net practice?
You can’t do that as such – preprocessor symbols are either “on” or “off” (defined or not), rather than having numeric values.
You could easily define a BETA preprocessor symbol though, in appropriate project configurations. Then you can just remove it when you’re out of beta.
(I’m not sure it’s generally a good idea to have conditionalized code like that, mind you. If you’re not going to execute that code until you’re out of beta, how will you beta test that code?)