Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
 Console Applications
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
.NET Framework Developer's Guide 
Building Console Applications 

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 In property is a System.IO.TextReader object, whereas the values of the Out and 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 Out property to a System.IO.StreamWriter, which encapsulates a FileStream by means of the Console.SetOut method. The Console.In and Console.Out properties do not need to refer to the same stream.

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.

NoteNote

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 running under Visual Studio, set the project's Common Properties/General/Output 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 Overview.

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Secuirty Model of Console Applications vs Windows-based formless applications      pmasclark   |   Edit   |   Show History
There needs to be more explanation of the differences in security and how these two distinct apps behave.  There have been several cases where Console applications have run without the proper security when created as true console applications.  What is the difference in the secruity have these two application types?
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker