Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C#

Console.WriteLine: practical reference

Console.WriteLine: practical reference: Console.WriteLine writes a formatted representation to the current standard output and appends TextWriter.NewLine.

Version: .NET API; verified on .NET 10.0.14

Syntax

Console.WriteLine(value)

Console.WriteLine writes a formatted representation to the current standard output and appends TextWriter.NewLine.

Use it for console-program messages and simple CLI results; use structured logging and the proper stdout or stderr stream for production diagnostics.

Formatting overloads use composite formatting and the current culture; an invalid placeholder index throws FormatException, and WriteLine does not escape data for a terminal or protocol.

A redirected Console.Out can use another encoding or throw IOException; null in applicable overloads writes an empty representation before the line ending.

The complete program actually uses Console.WriteLine; its exact expected stdout is value=7.

Examples

using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;

Console.WriteLine("value={0}", 7);

Result

value=7

The complete program actually uses `Console.WriteLine`; its exact expected stdout is `value=7`.

Sources