O'Reilly logo

C# Primer Plus by Klaus Michelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 21

Answers to Chapter 21 Review Questions

1: How can you make the code between #if and #endif of the following lines be included in the compilation
#if TRIALEDITION
    <Some code>
#endif
A1: By letting the following line be the first line in the source code:
#define TRIALEDITION
2: Is the second line in the following two lines of code valid? Why or why not?
using System;
#define
A2: No, it is invalid. #define and #undef must precede any non-preprocessor directives in the source code.
3: Add the necessary preprocessor directives and identifiers to the following lines of code, so that <Code part 1> is excluded from the compilation and <Code part 2> is included.
...
#if
    <Code part 1>
#endif
...
#if
    <Code part 2>
#endif
...
A3:
 #undef PART1 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required