System.Console.SetOut Method

Sets the Console.Out property to the specified System.IO.TextWriter object.

Syntax

public static void SetOut (System.IO.TextWriter newOut)

Parameters

newOut
A stream that is the new standard output.

Exceptions

TypeReason
ArgumentNullException newOut is null.

Remarks

By default, the Console.Out property is set to the standard output stream.

A System.IO.StreamWriter that encapsulates a System.IO.FileStream can be used to send output to a file. For example:

code reference: System.Console.SetOut#1

Permissions

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0