21. Preprocessing, XML Documentation, and Attributes



You will learn about the following in this chapter:

  • C#'s preprocessor directives

  • How to mark different parts of your code with preprocessor directives

  • How to easily exclude code from being compiled with preprocessor directives

  • A brief introduction to automated program documentation

  • What a documentation comment is

  • How to let the compiler turn documentation comments into well-formed XML program documents

  • What an attribute is

  • How to add additional declarative information to C#'s elements by using attributes

Even though the three subjects discussed in this chapter (preprocessor directives, XML documentation, and attributes) are not directly related, they are similar in that they are all separate from the core logical constructs that provide the main functionality of a C# program.

Preprocessor directives can be viewed as controlling the compilation process rather than being part of what is being compiled. The documentation comments used to produce XML documents are, like conventional comments, completely ignored by the compiler; and attributes are not compiled into MSIL but are added to an assembly's metadata instead.

Preprocessor directives is a relatively simple and limited subject of which the key aspects are discussed in this chapter.

XML documentation is a larger subject and only a brief introduction is provided here.

Attributes is a vast and advanced subject with many exciting possibilities. Even though this chapter only shows you a glimpse of what you can do with them, I hope it will inspire you to continue exploring this fascinating subject.


C# Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 286
Authors: Stephen Prata

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net