Skip to main content

Outputs

You've already seen how to print to the console:

Console.WriteLine("wow im printing")

Console.WriteLine()​

Console.WriteLine() is a function & it prints whatever is inside the parentheses () to the screen.

Console.WriteLine("Hello World"); // Prints: Hello World (quotes needed cause string)
Console.WriteLine(357); // Prints: 357 (no quotes needed cause int)

string myVariable = "Goodbye World";
int myOtherVariable = 35;

Console.WriteLine(myVariable); // Prints: Goodbye World
Console.WriteLine(myOtherVariable); // Prints: 35

As the name implies, WriteLine prints its content and then breaks to a new line. That way, the next output starts fresh below it.

Console.Write()​

Console.Write() prints without breaking the line, so everything ends up on the same line:

Console.Write("Hello World");
Console.Write(357);

string myVariable = "Goodbye World";
int myOtherVariable = 35;

Console.Write(myVariable);
Console.Write(myOtherVariable);