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 TextWriter Error{get; }
public static TextReader In{get; }
public static TextWriter Out{get; }
// Public Static Methods
public static Stream OpenStandardError( );
public static Stream OpenStandardError(int bufferSize);
public static Stream OpenStandardInput( );
public static Stream OpenStandardInput(int bufferSize);
public static Stream OpenStandardOutput( );
public static Stream OpenStandardOutput(int bufferSize);
public static int Read( );
public static string ReadLine( );
public static void SetError(System.IO.TextWriter newError);
public static void SetIn(System.IO.TextReader newIn);
public static void SetOut(System.IO.TextWriter newOut);
public static void Write(bool value);
public static void Write(char value);
public static void Write(char[ ] buffer);
public static void Write(char[ ] buffer, int index, int count);
public static void Write(decimal value);
public static void Write(double value);
public static void Write(int value);
public static void Write(long value);
public static void Write(object value);
public static void Write(float value);
public static void Write(string value);
public static void Write(string format, object arg0);
public static void Write(string format, params object[ ] arg);
public static void Write(string format, object arg0, object arg1);
public static void Write(string format, object arg0, object arg1, object arg2);
public static void Write(string format, object arg0, object arg1, object arg2,
object arg3);
public static void Write(uint value);
public static void Write(ulong value);
public static void WriteLine( );
public static void WriteLine(bool value);
public static void WriteLine(char value);
public static void WriteLine(char[ ] buffer);
public static void WriteLine(char[ ] buffer, int index, int count);
public static void WriteLine(decimal value);
public static void WriteLine(double value);
public static void WriteLine(int value);
public static void WriteLine(long value);
public static void WriteLine(object value);
public static void WriteLine(float value);
public static void WriteLine(string value);
public static void WriteLine(string format, object arg0);
public static void WriteLine(string format, params object[ ] arg);
public static void WriteLine(string format, object arg0, object arg1);
public static void WriteLine(string format, object arg0, object arg1, object arg2);
public static void WriteLine(string format, object arg0, object arg1, object arg2,
object arg3);
public static void WriteLine(uint value);
public static void WriteLine(ulong value);
}