Fundamentals of Computer Programming with C# HTML version

Chapter 4. Console
Input and Output
In This Chapter
In this chapter we will get familiar with the console as a tool for data input
and output. We will explain what it is, when and how to use it, and how most
programming languages access the console. We will get familiar with some of
the features in C# for user interaction: reading text and numbers from the
console and printing text and numbers. We will also examine the main
streams for input-output operations Console.In, Console.Out and
Console.Error, the Console and the usage of format strings for printing
data in various formats.
What Is the Console?
The Console is a window of the operating system through which users can
interact with system programs of the operating system or with other console
applications. The interaction consists of text input from the standard input
(usually keyboard) or text display on the standard output (usually on the
computer screen). These actions are also known as input-output
operations. The text written on the console brings some information and is a
sequence of characters sent by one or more programs.
For each console application the operating system connects input and output
devices. By default these are the keyboard and the screen but they can be
redirected to a file or other devices.
Communication between the User and the Program
A lot of programs communicate in some way with the user. This is necessary
for the user in order to give instructions to them. Modern communication
methods are many and various: they can be through graphical or web-
based interface, console or others. As we mentioned one of the tools for
communication between programs and users is the console, which is
becoming less and less used. This is because the modern user interface
concepts are more convenient and intuitive to work with, from a user’s