#if DEBUG
string s = @"
# text";
#endif
If DEBUG is defined the above code builds without error using Visual Studio 2017.
If DEBUG is not defined, the build fails with this error:
error CS1024: Preprocessor directive expected
The issue has been reported to the C# language design community here.
I can work around the problem by using non-verbatim strings:
#if DEBUG
string s = "\n" +
"# text";
#endif
In my particular use case I would rather keep my strings verbatim. Is there a different - possibly better - way to work around this problem?