Lecture overview -- Keyboard shortcut: 'u'  Previous page: Functions -- Keyboard shortcut: 'p'  Next page: Comments -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 16 : 43
Object-oriented Programming in C#
Introduction to C#
Input and output

Input and output (IO) is handled by a number of different classes in C#. In both C and C# there very few traces of IO in the languages as such.

Output to the screen and input from the keyboard is handled by the C# Console class

File IO is handled by various Stream classes in C#

  • Similarities

    • Console.Write and Console.WriteLine in C# correspond to printf in C

  • Differences

    • There is no direct counterpart to C's scanf in C#

    • Comprehensive formatting support of DateTime objects in C#

/user/normark/oop-csharp-1/sources/c-sharp/introductory-examples/io/o-demo.csDemonstrations of Console output in C#. This program is explained


/user/normark/oop-csharp-1/sources/c-sharp/introductory-examples/io/o-outputOutput from the output demo program.


/user/normark/oop-csharp-1/sources/c-sharp/introductory-examples/io/i-demo.csDemonstrations of Console input in C#. This program is explained


/user/normark/oop-csharp-1/sources/c-sharp/introductory-examples/io/i-outputA sample dialog with the Console IO demo program.

Input is shown in bold style. Boldface items represent the input entered by the user of the program.