Console Class
Summary
Represents the standard input, output, and error streams for console applications. This class cannot be inherited.
Members
Properties
In TextReader In { get; }
Gets the standard input stream. In essence, it is the input buffer of the command prompt.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Out TextWriter Out { get; }
Gets the standard output stream. In essence, it is the output buffer of the command prompt.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Error TextWriter Error { get; }
Gets the standard error stream. In essence, it is the output buffer of the command prompt.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Methods
Beep() static void Beep()
Emits a console beep.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Example:
Console.Beep();
Clear() static void Clear()
Clears the console buffer and sets the title to the current title string.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Example:
Console.Clear();
Read() static int Read()
Reads the next character from the standard input stream and returns it as an integer.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Example:
int charCode = Console.Read();
ReadLine() static string ReadLine()
Reads the next line of characters from the standard input stream and returns it as a string.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Example:
string input = Console.ReadLine();
Write(string value) static void Write(string value)
Writes the specified value to the standard output stream.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Example:
Console.Write("Hello, ");
WriteLine(string value) static void WriteLine(string value)
Writes the specified value, followed by the current line terminator, to the standard output stream.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Example:
Console.WriteLine("World!");
WriteLine() overloads static void WriteLine()
Writes the current line terminator to the standard output stream.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Example:
Console.WriteLine(); // Writes a blank line
There are also overloads for writing various data types, like integers, booleans, etc.