C# Comments
A note in the Pine program is for the person reading the file. The screen stays pine. Console.WriteLine("pine"); is still the line that writes that word. This page adds the note in two shapes, shows that pine is still the only line, and then shows the one placement that removes pine. You are not installing the SDK again. You are not re-reading which line is Main. Keep the public class named Pine and keep the writing command active in the file you keep.
A note is not a command
A command is a line C# carries out. Console.WriteLine("pine"); is a command. It writes pine and ends the line. A note is text you leave in the file so that you, or the next reader, remember something. The compiler and the runtime skip a note. Skipping means the note is not carried out, and it is not written on the screen. The letters of the note stay in the file after the run. You can open the file and read them. You cannot find them on the screen. The screen still has one line, and that line is pine, as long as the writing command itself is not the note.
There are two shapes. A line note starts with two slashes, //. C# skips from those two slashes through the end of that same line. The next line is a normal line again. A block note starts with /* and ends at the first */. C# skips everything between those two marks, including the line breaks. A block note can sit on one line or across several. Both shapes are notes. Neither shape writes the screen. The slashes are not printed. The stars are not printed. The words you put between them are not printed.
The file you keep
Keep this teaching shape. It has a line note above the writing command, another line note on the writing command’s own line, and a line note near Main. The writing command is still there, and it is not behind a slash.
using System;
public class Pine
{
// the teaching type is Pine
public static void Main()
{
// a note for the reader
Console.WriteLine("pine"); // the screen is this word
}
}
Read it from the top, and decide for each line whether the screen receives it. The using System; line prepares short names and does not write the screen. The class line is still public class Pine. That line names the type and does not write the screen. The next line is // the teaching type is Pine. The two slashes start a note, so those words are for you. The screen does not show them. It also does not show the slashes. The line public static void Main() is where the runtime starts, and none of those words are on the screen. That has not changed from First Program.
Inside Main, the line // a note for the reader is only a note. The runtime reaches it, skips it, and goes to the next line. The next line is the one that matters: Console.WriteLine("pine"); // the screen is this word. Read that line as two parts split by the slashes. Before the slashes, the command is Console.WriteLine("pine");. That command writes pine and ends the line. After the slashes, the words the screen is this word are a note. They sit on the same line as the command, and they are still skipped. A note does not have to occupy a line by itself. If // appears after a finished command, the command runs and the rest of the line does not. The semicolon is what finishes the command. The slashes after the semicolon start the note. Leave that semicolon where it is. The screen shows pine. It does not show the screen is this word. It does not show a second line.
Run it the same way as after install. In the project folder, type dotnet run. The screen shows pine. One line. No quotes. No slashes. No second line. The word pine is still the word between the quotes. It is not a word you typed in the command, and it is not a word you typed in a note. The notes do not make the build fail, and they do not print themselves.
A block note
A block note is the other shape. You use it when the note is longer than one line, or when you want the end of the note to be a mark you choose, not the end of the line. The opening mark is /*. The closing mark is */. C# skips from the opening through the closing, and the first */ is the end. A later */ is not part of this note, because the note already ended. This page uses one block note, so you will see one opening and one closing.
Replace the line notes inside Main with one block note, and leave the writing command in place. The screen does not change. This is the second file. You are looking at what the note looks like. The file you were keeping used line notes. This one uses a block note. Both write pine.
using System;
public class Pine
{
public static void Main()
{
/* a note
across two lines */
Console.WriteLine("pine");
}
}
The block note begins on the line that starts with /*. The words a note are inside it. The next line, across two lines, is inside it too, because the closing */ has not appeared yet. The */ at the end of that second line ends the note. C# then runs Console.WriteLine("pine"); because that command is outside the note, below the closing mark. The screen shows pine. The words a note and across two lines are not on the screen. The stars and the slashes are not on the screen. If you move the */ up so that it sits on the first line, right after a note, then the second line is no longer inside the note. That second line would have to be a real C# line, and across two lines is not a command. The build would write an error instead of staying quiet. On this page the */ stays at the end of the second line, so the whole note is skipped and the build stays quiet.
Do not try to put one block note inside another. The first */ ends the note, even if you meant that */ to end an inner note. After that first closing mark, C# is reading commands again. This page does not nest notes. One opening, one closing, then the writing command.
The mistake that removes pine
The note and the writing command are different lines, or different parts of one line, in the files above. The mistake is to put the two slashes in front of the writing command, so that the command becomes the note. Save this third shape only long enough to see the empty screen, then put the writing command back. This is not the file you keep.
using System;
public class Pine
{
public static void Main()
{
// Console.WriteLine("pine");
}
}
dotnet run then writes nothing useful on the screen for this teaching check. There is no pine. There is no empty quoted word. There is no second line. The screen is blank because the command that used to write pine is behind //. The letters Console.WriteLine("pine") are still in the file, and you can read them, but they are a note now. The quotes do not save them. Quotes mark a word inside a command. They do not turn a note back into a command. The two slashes in front decide, and they decide that the rest of the line is for the reader.
Put the file back to the one you keep. The writing line must be Console.WriteLine("pine"); with the note, if you want one, after the semicolon. Then dotnet run writes pine again. If the screen is blank, look for // before Console. That is the whole check. You do not reinstall the .NET SDK for a blank screen caused by a note. Keep leftover Java System.out.println habits off this page when you practice the C# writing line. Keep inventing ASP.NET routes off this page.
The screen is still pine
You can now put a note in the Pine file without changing the screen. A line note starts with //. A block note starts with /* and ends at the first */. The screen of the file you keep is pine, written by Console.WriteLine("pine");. If // stands in front of that command, the screen has no line. A note can contain any words, including Pine, Main, and pine. Those words are still not on the screen. The next page changes how output lines are written, so the screen can show more than one short habit. The notes on this page stay notes.
🧠 Test Your Knowledge
Test Your Knowledge
Challenge yourself with this interactive quiz and see how well you understand the topic
📝 Instructions
- Read each question carefully
- Select the best answer for each question
- You can retake the quiz as many times as you want
- Your progress will be shown at the top