1.14. Printing to the Screen

Most applications communicate information to users by displaying messages via the application's GUI. However, it is also useful at times to be able to display simple text messages to the command-line window from which we are running a program as a "quick and dirty" way of verifying that a program is working properly (you'll learn how to run C# programs from the command line in Chapter 13). Until we discuss how to craft a C# GUI in Chapter 16, this will be our program's primary way of communicating with the "outside world."

To print text messages to the screen, we use the following syntax:

Console.WriteLine(expression to be printed);

The Console.WriteLine method can accept very complex expressions and does its best ...

Get Beginning C# 2008 Objects: From Concept to Code now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.