Sponsored Ad

Tuesday, October 20, 2009

C# Internal Comments within the Source Files

C# uses the traditional C - type single - line ( // ... ) and multiline
( /* ... */ ) comments:
// This is a single-line comment
/* This comment
spans multiple lines. */

 

Everything in a single - line comment, from the // to the end of the line, will be abandoned by the compiler, and aggregate from an opening /* to the next */ in a multiline comment combination will be ignored. Obviously, you can`t cover the aggregate */ in any multiline comments, because this will be treated
as the end of the comment.

It is actually possible to put multiline comments within a line of code:
Console.WriteLine(/* Here’s a comment! */ “This will compile.”);

 

Use inline comments with care because they can make code hard to read. However, they can be useful
when debugging if, say, you temporarily want to try running the code with a different value somewhere:

 

DoSomething(Width, /*Height*/ 100);

Comment characters included in string literals are, of course, treated like normal characters:

string s = “/* This is just a normal string .*/”;

0 comments:

Post a Comment

Sponsored Ad

Website Update

Followers