Adding comments in C# or VFP


//, /*, */


Note, *, &&

C# Syntax Notes

Comments in C# are similar to those in C, Java and Javascript. There are two styles: // marks a single line and the matching pair /* and */ mark a block of comments. Such a block can cover anything from a few characters within a line of code to several lines of code.

The // marker can be used at the start of a line or in the middle of a line.

// This comment fills the whole line
SqlConnection con = new SqlConnection(conString);
con.Open(); // This comment is part of a line

/* These comments are spread over several lines ...
  SqlConnection con = new SqlConnection(connectStr);
... and can rem out a block of code. */

The danger with the block style of comment is that any mistake in the closing tag means that all the text until the next correctly-formed closing tag will be accidentally turned into a comment.

VFP Syntax Notes

There are three styles of comment in Visual FoxPro. The * and Note markers are similar. They must be at the start of a line and they mark that entire line as a comment:

* If an asterisk is the first character
* on a line then the entire line is a
* comment.

Note If 'Note' is the first word on
Note a line then the entire line is a
Note comment.

The Note style dates from dBaseII and is only supported in Visual FoxPro for backwards compatibility. Comments written in this way can be very difficult to understand because you tend to include the word "Note" when you're reading them.

The third style of FoxPro comment uses a double ampersand &&. This can be placed anywhere in a line and marks the start of a comment which runs to the end of the line

USE customer && Open the table

Visual FoxPro does not have a style of comment which will mark a block in a program but you can select several lines of text, right-click, and select Comment to indentify them as comments. This tool uses *!* to mark the comments so you can easily see which code has been remmed out in this way. The Uncomment option on the right-click menu will remove the *!* comment marks in the text selected.

Arrays  |  Language index  |  Constants

Related Items

Site Map

Site map of the Alvechurch Data site

Read More

VFP and C#.

C# is very different from Visual FoxPro so conversion from one language to the other is difficult.

Read More

Constants in C# and VFP

Declaring constants in C# and Visual FoxPro

Read More

Variables in C# and VFP

Declaring variables in C# and Visual FoxPro

Read More

Generate a connection string for OLEDB

Generate a connection string for OLEDB

Generate the connection string for an OLEDB provider such as VFPOLEDB.

Read More