Review Questions



How can you make the code between #if and #endif of the following lines be included in the compilation

 #if TRIALEDITION     <Some code> #endif 

Is the second line in the following two lines of code valid? Why or why not?

 using System; #define 

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 ... 

What is the major difference between standard comments and program documentation?


What does a documentation comment consist of? Give an example.


Which command must you give to the compiler to let it transform the documentation comments into a separate XML document?


What is the main purpose of attributes?


Can any attribute be used to decorate any code element?


Name a couple of .NET's predefined attributes and briefly describe what they are used for.


As mentioned earlier, .NET contains an attribute called XmlArrayAttribute; it exists in the System.Xml.Serialization namespace. Which of the following annotations are correct (there can be more than one). (Assume the line using System.Xml. Serialization; is included at the beginning of the source):

  1. [System.Xml.Serialization.XmlArrayAttribute]

  2. [XmlArrayAttribute]

  3. [XmlArray]

  4. [Xml]

  5. [Array]


What is an attribute's positional parameter? Give an example.


Suppose your source code contains a method with the following header:

 public void StartOperation() {     ... } 

Which attribute can you use to prevent any methods from calling this method? Provide the necessary annotation.


Can you use the same procedure as in question 12 to prevent any calls to the following method? Why or why not?

 public int Sum(int x, int y) {     ... } 

What is a named parameter?


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

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: