Comments in C#
As you know, commenting your code helps make it a good deal clearer. C# supports three types of comments, C++-style // comments, C-style /*...*/ comments, and XML-style /// comments.
// Comments
The // style of comments are the most commonly used in C#, as in C++. These comments are single-line comments, making the compiler ignore the text following the //:
class ch01_01
{
// Display the message.
static void Main()
{
System.Console.WriteLine("Hello from C#.");
}
}
These comments don't have to be on their own line, of course; you can add them to any line, and the compiler will stop looking for code when it reaches the // on a line:
class ch01_01
{
static void Main()
{
System.Console.WriteLine("Hello from C#."); // Show message. ...
Get Microsoft® Visual C#® .NET 2003 Kick Start 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.