Applications in the .NET Framework can use the System.Console class to read characters from and write characters to the console. Data from the console is read from the standard input stream, data to the console is written to the standard output stream, and error data to the console is written to the standard error output stream. These streams are automatically associated with the console when the application starts and are presented as the In, Out, and Error properties, respectively.
The value of the Console.In property is a System.IO.TextReader object, whereas the values of the Console.Out and Console.Error properties are System.IO.TextWriter objects. You can associate these properties with streams that do not represent the console, making it possible for you to point the stream to a different location for input or output. For example, you can redirect the output to a file by setting the Console.Out property to a System.IO.StreamWriter, which encapsulates a System.IO.FileStream by means of the Console.SetOut method. The Console.In and Console.Out properties do not need to refer to the same stream.
For more information about building console applications, including examples in C#, Visual Basic, and C++, see the documentation for the Console class.
If the console does not exist, as in a Windows-based application, output written to the standard output stream will not be visible, because there is no console to write the information to. Writing information to an inaccessible console does not cause an exception to be raised.
Alternately, to enable the console for reading and writing within a Windows-based application that is developed using Visual Studio, open the project's Properties dialog box, click the Application tab, and set the Application type to Console Application.
Console applications lack a message pump that starts by default. Therefore, console calls to Microsoft Win32 timers might fail.
The System.Console class has methods that can read individual characters or entire lines from the console. Other methods convert data and format strings, and then write the formatted strings to the console. For more information on formatting strings, see Formatting Types.