Writing Code in C#

A good programming habit is to add comments.

There are two ways to add a comment.:
A single line comment begins with //
The compiler will ignore everything after the //
// Programmer: Janet Joy
// The Hello World program with code.

this.BackColor = Color.SlateBlue; //a deep gray

A multiline comment starts with /* and ends with */


  /*  Programmer: Janet Joy
Hello World with code
  • The C# compiler ignores comments.
  • Comments are a way for the programmer to leave notes for themselves.
  • Add a comment with your name and an overview of what the program does.
  • The multiline comment is also useful to "comment out" code that doesn't work.
  • Comments are shown in green.

Commenting Conventions:

  • Place the comment on a separate line, not at the end of a line of code.
  • Begin comment text with an uppercase letter.
  • End comment text with a period.
  • Insert one space between the comment delimiter (//) and the comment text.

NEXT: Code Explanation