13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 9 Lexical structureclass Hello{static void Main() {System.Console.WriteLine(@"hello,#if Debugworld#elseNebraska#endif");}}results in the output:hello,#if Debugworld#elseNebraska#endifIn peculiar cases, the set of pre-processing directives that is processed might depend on the evaluation of the ppexpression.The example:#if X/*#else/* */ class Q { }#endifalways produces the same token stream (class Q { }), regardless of whether or not X is defined. If X is defined,the only processed directives are #if and #endif, due to the multi-line comment. If X is undefined, then threedirectives (#if, #else, #endif) are part of the directive set. end example]9.5.5 Diagnostic directivesThe diagnostic directives are used to explicitly generate error and warning messages that are reported in the sameway as other compile-time errors and warnings.pp-diagnostic::whitespace opt # whitespace opt error pp-messagewhitespace opt # whitespace opt warning pp-messagepp-message::new-linewhitespace input-characters opt new-line[Example: The example#warning Code review needed before check-in#if Debug && Retail#error A build can't be both debug and retail#endifclass Test {…}always produces a warning (“Code review needed before check-in”), and produces a compile-time errorif the pre-processing identifiers Debug and Retail are both defined. Note that a pp-message can containarbitrary text; specifically, it need not contain well-formed tokens, as shown by the single quote in the wordcan’t. end example]9.5.6 Region controlThe region directives are used to explicitly mark regions of source code.pp-region::pp-start-region conditional-section opt pp-end-region67

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!