Information Technology Reference
In-Depth Information
More About Comments
There are several other important things you need to know about comments:
￿
Nested comments are not allowed. Only one comment can be in effect at a time.
￿
The comment that starts first is in effect until the end of its scope. The scope for partic-
ularly comment types is as follows:
-
For single-line comments, the end of the current line
-
For delimited comments, the first end delimiter encountered
The following attempts at comments are incorrect:
Opens the comment
/* This is an attempt at a nested comment.
/* Ignored because it is inside a comment
Inner comment
*/ Closes the comment because it is the first end delimiter encountered
*/ Syntax error because it has no opening delimiter
Opens the comment Ignored because it is inside a comment
// Single-line comment /* Nested comment?
*/ Incorrect because it has no opening delimiter
Documentation Comments
C# also provides a third type of comment: the documentation comment . Documentation com-
ments contain XML text that can be used to produce program documentation. Comments of
this type look like single-line comments, except that they have three contiguous slashes rather
than two. I will cover documentation comments in Chapter 23.
The following code shows the form of documentation comments:
/// <summary>
/// This class does...
/// </summary>
class Program
{
...
Search WWH ::




Custom Search