C# Console WriteLine() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Console

Definition

In C#, Console.WriteLine writes text to standard output and then ends the line. The next print starts on a new line.

Calling WriteLine() with no arguments prints only a blank line. Overloads accept strings, numbers, and composite format strings—the everyday tool for showing results in console apps.

This is a static member of System.Console. You call it with the type name, such as Console.WriteLine(...). Console is the everyday API for reading from standard input and writing to standard output in C# console apps.

Syntax

Pass a message, a value, a format string, or nothing for a blank line.

C#
Console.WriteLine("Hello");
Console.WriteLine("x = {0}", 10);
Console.WriteLine();
CallWhat it does
Console.WriteLine("Hi")Prints Hi and a newline.
Console.WriteLine("n={0}", 5)Formats, prints, then newline.
Console.WriteLine()Prints an empty line.

Write is the sibling that skips the newline. Both send text through Console.Out.

Library declarations
C#
public static void WriteLine();
public static void WriteLine(string? value);
public static void WriteLine(string format, params object?[]? arg);
// many overloads for common types

Parameters

ParameterDescription
(none)Empty call prints only a newline.
valueText or value to print before the newline.
format, argComposite format string and replacement values.

Return Value

Return ValueDescription
voidNothing is returned. Output goes to Console.Out.

C# Examples

Example 1 — Print Three Separate Lines

Each WriteLine ends with a newline so messages stack vertically.

C#
using System;

class Program {
    static void Main() {
        Console.WriteLine("Line 1");
        Console.WriteLine("Line 2");
        Console.WriteLine("Line 3");
    }
}

How It Works

  1. One call, one line. Each message appears on its own row.
  2. Automatic newline. You do not type \\n yourself for the break.
  3. Order matters. Calls run top to bottom in the order written.
  4. Everyday output. This is the usual first method beginners learn.

Example 2 — Format a Score Line

Insert numbers into a sentence with placeholders.

C#
using System;

class Program {
    static void Main() {
        string player = "Sam";
        int score = 120;
        Console.WriteLine("{0} scored {1} points.", player, score);
    }
}

How It Works

  1. {0} and {1}. Placeholders map to the following arguments in order.
  2. Readable sentence. Format keeps text and data in one string.
  3. Types convert. The int is turned into text for display.
  4. Ends the line. The period and newline finish the message.

Example 3 — Add Space With Empty WriteLine

Use a no-argument call to separate groups of output.

C#
using System;

class Program {
    static void Main() {
        Console.WriteLine("Header");
        Console.WriteLine();
        Console.WriteLine("Body text");
    }
}

How It Works

  1. Empty call. WriteLine() prints only the line ending.
  2. Visual gap. A blank row appears between Header and Body text.
  3. Grouping. Blank lines make sections easier to scan.
  4. Still void. Like other WriteLine overloads, nothing is returned.

Frequently Asked Questions

It prints text (or nothing) and then moves to the next line on the console.
WriteLine adds a newline; Write does not.
Yes. Console.WriteLine() with no arguments prints a blank line.
Yes. Overloads accept many types, and format strings can mix text and values.
Learn Write for same-line prompts, then ReadLine for keyboard input.

Back to the method index

See all 19 System.Console method guides grouped by what they do.

Method index →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

7 people found this page helpful