Dec 29, 2010 4:27 pm
AlcibiadeHi guys,
If in my code I write
#if USE_VAR
.....
#endif
I must type or delete the USE_VAR in the conditional compilation symbols
textbox.
Is there a way to keep always the string in the textbox but using it
when I want?
For example if I want to use it I can write
USE_VAR=1 or USE_VAR=true or USE_VAR="1"
on the other hand I 'll use
USE_VAR=0 or USE_VAR=false or USE_VAR="0"
Thanks
Dec 29, 2010 6:50 pm
Peter DunihoOn 12/29/10 8:27 AM, Alcibiade wrote:
> Hi guys,
>
> If in my code I write
> #if USE_VAR
> ......
> #endif
>
> I must type or delete the USE_VAR in the conditional compilation symbols
> textbox.
>
> Is there a way to keep always the string in the textbox but using it
> when I want?
> For example if I want to use it I can write
>
> USE_VAR=1 or USE_VAR=true or USE_VAR="1"
> on the other hand I 'll use
> USE_VAR=0 or USE_VAR=false or USE_VAR="0"
>
> If in my code I write
> #if USE_VAR
> ......
> #endif
>
> I must type or delete the USE_VAR in the conditional compilation symbols
> textbox.
>
> Is there a way to keep always the string in the textbox but using it
> when I want?
> For example if I want to use it I can write
>
> USE_VAR=1 or USE_VAR=true or USE_VAR="1"
> on the other hand I 'll use
> USE_VAR=0 or USE_VAR=false or USE_VAR="0"
C# #defines are strictly "defined" and "not defined". If you want a
project-wide definition, you'll have to maintain that explicitly in the
project settings. Note that you can define additional build
configurations, so that some include the definition and some do not.
If the symbol is to apply only in a single source code file, you can
also just define it at the beginning of the file. For example:
#define USE_VAR
Then you can comment it out when you don't want the symbol to apply.
Manipulating the build configuration is more maintainable, but a) can
get out of hand if you're dealing with permutations of multiple symbols,
and b) might be overkill if you're just including the conditional
compilation for prototyping, rather than intending to keep it in production.
Pete
Previous Thread: Re: MVC Application using EntityFramework
Next Thread: TextWriter problem.