O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

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

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

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