I\'ve been writing an #if DEBUG
, #else
, #endif
fragment of code, and I noticed that Visual Studio doesn\'t let me use autocomplete to
It is purpose of conditional compilation, it is working as intended. With conditional compilation application can ignore certain code at compilation. Your application in Visual Studio is running in Debug Mode so compiler is ignoring code inside #else
part.
Run your application in Release mode then #else
code will be available but #if DEBUG
will not be available.
Update
For checking both #if DEBUG
& #else
you need to run application twice.
1.Once in debug mode in which code with #if DEBUG
like :
here application is in debug mode so #if DEBUG
condition code is active..
#else
condition. Here other part will be able to use autocomplete & debug too.
Refer microsoft docs for more info on this:
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/debug-compiler-option
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/listed-by-category