System.Console

Provides access to the standard input, output, and error streams for console applications. This class cannot be inherited.

Namespace: System
Assembly: System.Runtime.Extensions (in .NET Core, .NET 5+)

Members

Properties

public static bool IsErrorRedirected { get; }

Gets a value that indicates whether the Error stream is redirected.

public static bool IsInputRedirected { get; }

Gets a value that indicates whether the In stream is redirected.

public static bool IsOutputRedirected { get; }

Gets a value that indicates whether the Out stream is redirected.

Methods

public static void Beep()

Emits a console-defined audio signal by making a **beep** sound.

public static void Beep();

public static void Beep(int frequency, int duration)

Emits a console-defined audio signal with a specified frequency and duration.

frequency
The frequency of the beep, in hertz.
duration
The duration of the beep, in milliseconds.
public static void Beep(int frequency, int duration);

public static int Read()

Reads the next character from the standard input stream and returns it as an integer.

Returns
The next character from the input stream, or -1 if there are no more characters or if an error occurs. The actual return type is int because the Stream class returns an int.
public static int Read();

public static string? ReadLine()

Reads the next line of characters from the standard input stream and returns it as a string.

Returns
The next line from the input stream, or null if the end of the input stream is reached.
public static string? ReadLine();

public static void Write(string value)

Writes the specified value to the standard output stream.

value
The value to write.
public static void Write(string value);

public static void WriteLine(string value)

Writes the specified string value, followed by the current line terminator, to the standard output stream.

value
The value to write.
public static void WriteLine(string value);

public static void WriteLine()

Writes the current line terminator to the standard output stream.

public static void WriteLine();
See Also