X hits on this document

801 views

0 shares

0 downloads

0 comments

63 / 396

C# LANGUAGE SPECIFICATION

class PurchaseTransaction { void Commit() { #if Debug CheckConsistency(); #if Trace WriteToLog(this.ToString()); #endif #endif CommitHelper(); } }

Except for pre-processing directives, skipped source code is not subject to lexical analysis. For example, the following is valid despite the unterminated comment in the #else section:

#define Debug// Debugging on

class PurchaseTransaction { void Commit() { #if Debug CheckConsistency(); #else /* Do something else #endif } }

Note, however, that pre-processing directives are required to be lexically correct even in skipped sections of source code.

Pre-processing directives are not processed when they appear inside multi-line input elements. For example, the program:

class Hello { static void Main() { System.Console.WriteLine(@"hello, #if Debug world #else Nebraska #endif "); } }

results in the output:

hello, #if Debug world #else Nebraska #endif

In peculiar cases, the set of pre-processing directives that is processed might depend on the evaluation of the pp-expression. The example:

50Copyright Microsoft Corporation 1999-2003. All Rights Reserved.

Document info
Document views801
Page views801
Page last viewedSun Dec 04 01:54:52 UTC 2016
Pages396
Paragraphs9401
Words133190

Comments