System.Console
Namespace: System
Assembly: System.Runtime.dll
Assembly: System.Runtime.dll
Provides access to the standard input, output, and error streams for console applications.
Properties
public static TextReader In { get; }
Gets the standard input stream.
public static TextWriter Out { get; }
Gets the standard output stream.
public static TextWriter Error { get; }
Gets the standard error stream.
public static ConsoleColor BackgroundColor { get; set; }
Gets or sets the background color of the console.
public static ConsoleColor ForegroundColor { get; set; }
Gets or sets the foreground color of the console.
public static bool KeyAvailable { get; }
Gets a value indicating whether a key press is waiting to be processed.
Methods
public static void Beep();
Emits a standard beep sound through the console speaker.
Example
System.Console.Beep();
public static int Read();
Reads the next character from the standard input stream and returns it as an integer.
public static string ReadLine();
Reads the next line of characters from the standard input stream and returns them as a string.
Example
string name = System.Console.ReadLine();
System.Console.WriteLine($"Hello, {name}!");
public static void Write(string value);
Writes the specified string value to the standard output stream.
public static void WriteLine(string value);
Writes the specified string value, followed by the current line terminator, to the standard output stream.
Example
System.Console.WriteLine("This is a message.");
System.Console.WriteLine(123);
public static void ResetColor();
Sets the foreground and background console colors to their defaults.