C# Output
Change the word between the quotes and the screen changes with it. The teaching type is still Pine, and the writing call is still Console.WriteLine. Last time the quotes held pine, so the screen was pine. Put a different word between those quotes, add a second writing line, and then see what the screen does when a writing line does not end the line. You are not installing the SDK again. Notes from the last page stay off this demo unless you put them back yourself.
The word between the quotes
Open the Pine file and find Console.WriteLine("pine");. The screen shows the word between the quotes. The quotes themselves are not letters for the screen. They mark where that word starts and where it ends. Change the word. Leave the rest of the line as it is: Console.WriteLine stays, the opening quote stays, the closing quote stays, and the semicolon stays. Only the letters between the quotes change. Where the file had pine, write leaf, all small letters. The line is now Console.WriteLine("leaf");. Save the file. The class name is still Pine, because the line public class Pine still names the type. This page does not rename the type.
The file you keep
Keep this teaching shape. It has one writing line, and that line holds leaf between the quotes. There is no note in this file. There is no second writing line yet.
using System;
public class Pine
{
public static void Main()
{
Console.WriteLine("leaf");
}
}
Read it from the top and decide what the screen can receive. The using System; line prepares short names and does not write the screen. The class line is public class Pine. That line names the type. It does not write the screen. The next line is public static void Main(). That is where the runtime starts. None of those words are letters for the screen. Inside Main there is one command: Console.WriteLine("leaf");. Console.WriteLine is the writing command. The quotes hold leaf. The semicolon ends the command. The runtime runs that command because it sits inside Main and it is not behind //. The screen receives leaf. It does not receive the quotes, the semicolon, the word Console, or the word Main.
Run it with dotnet run in the project folder. The screen shows leaf. One line. No quotes. No semicolon. The word pine is not on the screen, because pine is no longer between the quotes. If the screen still shows pine, the quotes still contain pine. Look at the letters between the quotes before you run again. You do not reinstall the .NET SDK for a screen that still says pine.
The screen copies the letters between the quotes, and it copies them as they are. Console.WriteLine("Leaf"); writes Leaf, with a capital L. Console.WriteLine("leaf"); writes leaf, with a small l. The file you keep uses the small l, so its screen is leaf and not Leaf. A space is also a letter the screen can show, if you type the space inside the quotes. Console.WriteLine("leaf stem"); writes one line, leaf stem, with the space that you put between the two words. The quotes still do not appear. This is one writing line, so it is one screen line, even though two words are inside it. An empty pair of quotes is different. Console.WriteLine(""); writes a line that has no letters, and then ends that line. The screen looks blank. The command did run. The quotes simply held nothing. That blank line is not the file you keep. The file you keep holds leaf.
A second line
One writing line gives one screen line. A second screen line needs a second writing line. Under Console.WriteLine("leaf"); add Console.WriteLine("stem");. Each command has its own quotes and its own semicolon. leaf stays in the first pair of quotes. stem, all small letters, goes in the second pair. The runtime runs the first command, ends that line, then runs the second command and ends that line too. The screen order is the file order. The command you wrote first is the line the screen shows first.
This is the second file. You are looking at two screen lines. The file you were keeping had one writing line and the screen was leaf. This one has two writing lines. Use it when you want to see this screen, then put the single writing line back if you want the file this page keeps.
using System;
public class Pine
{
public static void Main()
{
Console.WriteLine("leaf");
Console.WriteLine("stem");
}
}
Run dotnet run. The screen shows leaf, and the next line of the screen is stem. Two lines. leaf is on top because Console.WriteLine("leaf"); is the first writing command. stem is under it because Console.WriteLine("stem"); is the second. The quotes are on neither line. If stem is on top and leaf is under it, the two writing lines in the file are in that swapped order. The screen is not choosing an order of its own. Move the stem command back under the leaf command, save, and run again. You do not need a new kind of command to get the second line. You need a second Console.WriteLine, with its own word between its own quotes.
Write does not end the line
Look at the end of the writing command you have been using. WriteLine ends with the letters Line. Those letters are the line end. The command writes the letters between the quotes, and then it ends the line, so the next writing command starts on a fresh line. Write is the same writing helper without those letters. Console.Write("leaf"); writes leaf and does not end the line. The next Console.Write starts where that word stopped. Nothing in the command inserts a space for you. If the first quotes hold leaf and the second quotes hold stem, and neither pair holds a space, the screen shows leafstem as one line.
This is the third file. It is not the file you keep. Use it long enough to see the single line leafstem. Both commands are Write, not WriteLine. There is no space inside either pair of quotes.
using System;
public class Pine
{
public static void Main()
{
Console.Write("leaf");
Console.Write("stem");
}
}
Run dotnet run. The screen shows leafstem. One line. No space between leaf and stem. No quotes. leaf is still first, because Console.Write("leaf"); is the first command, and stem is glued on after it, because Console.Write("stem"); does not start a new line. If you see leaf and then stem on a second line, the commands in the file are WriteLine, not Write. The letters Line are still on the command, so each command ended its line. Take Line off both commands if the screen you want is the single word leafstem.
The program writes leafstem and finishes without ending the line. The terminal may draw its own prompt on that same line, after leafstem. The prompt belongs to the terminal. It is not a word from the Pine file, and it is not part of the line you are checking. Check the letters between the quotes: leafstem. Do not try to match the prompt. Windows and macOS draw different prompts, and this page does not teach those prompts. The program's line is the same on both: leafstem, with no line end after it.
A space has to be inside the quotes
If you want a space on that same line, the space has to be one of the letters between the quotes. The writing command will not invent it. Change the first command to Console.Write("leaf "); with a space after the f, still inside the quotes. Leave the second command as Console.Write("stem");. C# writes leaf, then writes the space you put after the f, then writes stem, and still does not end the line. The screen shows leaf stem. The space you see is the space that was inside the first quotes. A space typed outside the quotes, between the two commands, is only a gap in the file. It is not a letter for the screen. You can break the two commands onto two lines in the file, or put a blank line between them, and the screen is still one line. Line breaks in the file are not line ends on the screen. Only the line-ending command, WriteLine, ends a screen line. Write never does, no matter how the file is spaced around it.
The mistake that drops the quotes
The word the screen shows has to sit between quotes. The mistake is to delete the quotes and leave the word bare: Console.WriteLine(leaf);. leaf without quotes is not a word for the screen. C# reads it as a name, and this file does not have that name yet. The next page is about names. This page stops at the quotes. Keep this fourth shape only long enough to see that the build does not stay quiet, then put the quotes back. This is not the file you keep.
using System;
public class Pine
{
public static void Main()
{
Console.WriteLine(leaf);
}
}
Run dotnet run or build the project. This time the compiler writes an error. It does not stay quiet. The file is not fine, because leaf has no quotes and no meaning in this file yet. You do not need the exact words of that error. The useful fact is that the build wrote a line at all. When the build writes an error, there is no new screen to trust until the file is fine again. Put the quotes back, so the line is Console.WriteLine("leaf"); again. Save. Run again. Now the build stays quiet enough to run, and the screen shows leaf. The quotes were the whole repair. You do not reinstall the SDK, and you do not remove the writing line. A writing line with the quotes removed is not a blank screen from a note. A note would have left the build quiet. This mistake makes the compiler speak. Keep leftover Java System.out.println habits mapped to Console.WriteLine here, and System.out.print to Console.Write. Keep inventing ASP.NET routes off this page.
The screen is the quoted word
You can now change the screen by changing the letters between the quotes. Console.WriteLine("leaf"); writes leaf and ends the line. A second Console.WriteLine writes the next line, in the order you wrote the commands in the file. Console.Write writes its letters and does not end the line, so a following Write continues on that same line, and a space appears only when you put it inside the quotes. If the build writes an error on a bare word, the quotes are missing. Put the file back to the one you keep when you are done looking at leafstem. The writing line in the file you keep is Console.WriteLine("leaf"); and there is no second writing line. The next page gives a word a name, so a writing line can use that name instead of only a quoted word.
🧠 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