Introduction

We now introduce C# application programming, which facilitates a disciplined approach to application design. Most of the C# applications you will study in this book process information and display results. In this chapter, we introduce console applicationsthese input and output text in a console window. In Microsoft Windows 95/98/ME, the console window is the MS-DOS prompt. In other versions of Microsoft Windows, the console window is the Command Prompt.

We begin with several examples that simply display messages on the screen. We then demonstrate an application that obtains two numbers from a user, calculates their sum and displays the result. You will learn how to perform various arithmetic calculations and save the results for later use. Many applications contain logic that requires the application to make decisionsthe last example in this chapter demonstrates decision-making fundamentals by showing you how to compare numbers and display messages based on the comparison results. For example, the application displays a message indicating that two numbers are equal only if they have the same value. We carefully analyze each example one line at a time. We provide many fun and challenging problems in the chapter's exercises.

A Simple C# Application Displaying a Line of Text

Категории