Single-Line Comments
A single-line comment starts with two consecutive forward slashes and stretches until the end of the source line. You’ve seen numerous examples of this style already:
// Badvar mystery = GetSomething(); // what's the return type of GetSomething?var x = 2159940436; // answer immediately: int or long?
As you can see, the comment doesn’t necessarily need to stand on its own in a line of code; it can also be used just at the end of a line after some meaningful source code. But it can’t be used in the middle of a line of code because there’s no way to terminate the run of comment text.
This style of commenting has a technical advantage: There are no worries about nesting of comments, which, ...
Get C# 5.0 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.