Name
Console
Synopsis
The Console class provides static methods
that allow you to create console, or command-line, applications.
If you attempt to use these methods in a Windows Forms application,
they are ignored. For a console application, data is transmitted
through three streams. Input is received from the standard input
stream, output is written through the standard output stream, and
error data is written to the standard error output stream. These
streams are provided through the In
property, which is a System.IO.TextReader object,
and through the Out and
Error properties, which are
System.IO.TextWriter objects. You can use the
methods of these objects directly, or you can use the methods provided
by the Console class. For example, you can use the
Write() method to write any basic
data type to the console window (or use
WriteLine() to write data with a
trailing hard return). You can also use the
ReadLine() method to cause the console
window to wait for input. When the user presses
the Enter key, this method returns with a string containing the input characters
(except the final hard return).
You can use the SetIn(),
SetOut(), and
SetError() methods to bind the
console to different stream objects, such as
System.IO.FileStream. To reset the streams to their
default objects, use the methods prefixed with OpenStandard.
public sealed class Console { // Public Static Properties public static field TextWriter Error{get; } public static field TextReader In{get; } public static field ...