NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Console.SetOut

Redirects Console.Out to the specified TextWriter. By default, Console.Out is set to the system's standard output stream.

[Visual Basic]
Public Shared Sub SetOut( _
   ByVal newOut As TextWriter _
)
[C#]
public static void SetOut(
   TextWriter newOut
);
[C++]
public: static void SetOut(
   TextWriter* newOut
);
[JScript]
public static function SetOut(
   newOut : TextWriter
);

Parameters

newOut
The new standard output stream.

Exceptions

Exception Type Condition
ArgumentException newOut is null.
SecurityException The caller does not have SystemStreamsPermission to set the standard error stream.

Remarks

A StreamWriter that encapsulates a FileStream can be used, in order to send output to a file.

In multi-threaded programs, an application getting the exception IndexOutOfRangeException with an exception message about "Probable IO race condition detected while accessing a file or Console...", must be updated to use thread-safe console output. To do this, simply synchronize the console. Here's an example:

Console.SetOut(StreamWriter.Synchronized(Console.Out));

The caller must have SystemStreamsPermission to set the standard output stream.

See Also

Console Class | Console Members | System Namespace