C# A Programmer's Introduction, 1/e: Tour of the Book
In this section, we tour the chapters and appendices of
C#: A Programmer's Introduction. Several of the chapters contain an
Internet and Web Resources section that lists additional sources of C#
information. Please visit
www.deitel.com
and
www.prenhall.com/deitel,
for updated information and additional learning resources.
Chapter 1-Introduction to .NET and C#
The first chapter presented the history of the Internet,
World Wide Web and various technologies (such as XML and SOAP) that have led
to advances in how computers are used. We then introduced the Microsoft .NET
initiative and the C# programming language, including Web services. We explore
the impact of .NET on software development and software reusability. The
chapter concludes by touring the remainder of the book.
Chapter 2-Introduction to the Visual Studio®
.NET IDE
Chapter 2 introduces Visual Studio .NET, an integrated
development environment (IDE) that allows programmers to create C#
programs. Visual Studio .NET enables visual programming, in which
controls (such as buttons and text boxes) are "dragged" and "dropped" into
place, rather than added by writing code and typing it in. Visual programming
increases software-development productivity by eliminating many tedious
programming tasks. For example, a graphical user interface (GUI's) properties
(information such as size and color) can be modified through the Visual Studio
.NET environment, allowing changes to be made quickly and causing the results
to appear immediately on the screen. Rather than having to guess how the GUI
will appear while writing a program, programmers view the GUI exactly as it
will appear when the finished program runs. Visual Studio .NET also contains
advanced tools for debugging, documenting and writing code. The chapter
presents features of Visual Studio .NET, including its key windows and shows
how to compile and run programs. We provide an example of the capabilities of
Visual Studio .NET by using it to create a simple Windows application without
typing a single line of code.
Chapter 3-Introduction to C# Programming
This chapter introduces readers to our Live-CodeT approach.
Every concept is presented in the context of a complete working C# program and
is followed by one or more screen shots showing actual inputs and outputs as
the program executes. Our first program prints a line of text-we carefully
discuss each line of code. Our next program prints text to a
MessageBox, a
small message dialog defined by the FCL. This example demonstrates using FCL
classes programmatically. We then discuss how a program inputs data from its
users and how to write arithmetic expressions. The last example demonstrates
using the equality and relational operators to compare two numbers entered by
the user.
Chapter 4-Control Structures: Part 1
This chapter introduces the principles of structured
programming, a set of techniques that will help the reader develop clear,
understandable and maintainable programs. The first part of this chapter
presents program-development and problem-solving techniques. The chapter
demonstrates how to transform a written specification to a program by using
such techniques as pseudocode and top-down, stepwise refinement.
We then progress through the entire process, from developing a problem
statement into a working C# program. We build on information presented in the
previous chapter to create programs that are interactive (i.e., they change
their behavior to suit user-supplied inputs). The chapter then introduces the
use of control structures that affect the sequence in which statements are
executed. We discuss the three forms of program control-sequence, selection
and repetition-focusing on the
if/else
and while control
structures. Flowcharts (i.e., graphical representations that show the order in
which actions are executed) appear throughout the chapter, reinforcing and
augmenting the explanations. The chapter concludes with a program walkthrough
that expands upon the program created in Chapter 2. Readers combine their
programming skills with the visual programming skills introduced earlier to
create programs that are both visual and interactive.
Chapter 5-Control Structures: Part 2
Chapter 5 introduces more complex control structures and
the logical operators. It uses flowcharts to illustrate the flow of control
through each control structure, including the
for,
do/while
and switch
structures. We explain the
break and continue
statements and the logical operators. Examples include calculating compound
interest and printing the distribution of grades on an exam (with some simple
error checking). The chapter concludes with a structured programming summary.
Chapter 6-Methods
A method allows the programmer to create a block of code
that can be called upon from various points in a program. Larger programs can
be divided into interacting classes, each consisting of methods-this is
sometimes called the "divide and conquer" strategy. Programs are divided into
simple components that interact in straightforward ways. We discuss how to
create our own methods that can take inputs, perform calculations and return
outputs. We examine the FCL's
Math class, which contains methods for performing complex
calculations (e.g., trigonometric and logarithmic calculations). Recursive
methods (methods that call themselves) and method overloading, which allows
multiple methods to have the same name, are introduced. We demonstrate
overloading by creating two
Square methods that each take an integer (i.e., whole number) and a
floating-point number (i.e., a number with a decimal point), respectively. To
conclude the chapter, we create a graphical simulation of the "craps" dice
game, using the random-number generation techniques presented in the chapter.
Chapter 7-Arrays
Chapter 7 introduces arrays, our first data structure. Data
structures are crucial to storing, sorting, searching and manipulating large
amounts of information. Arrays are groups of related data items that allow the
programmer to access any element directly. Rather than creating 100 separate
variables that are all related in some way, the programmer instead can create
an array of 100 elements and access these elements by their location in the
array. We discuss how to declare and allocate arrays, and we build on the
techniques of the previous chapter by passing arrays to methods. Chapters 4
and 5 provide essential background for the discussion of arrays, because
repetition structures are used to iterate through elements in the array. The
combination of these concepts helps the reader create highly structured and
well-organized programs. We then demonstrate how to sort and search arrays. We
discuss multidimensional arrays (both rectangular and jagged), which can be
used to store tables of data. We introduce the
foreach structure,
which can be used to iterate through arrays.
Chapter 8-Object-Based Programming
Chapter 8 serves as our introduction to the powerful
concepts of objects and classes (i.e., programmer-defined types). As mentioned
in Chapter 1, object technology has led to considerable improvements in
software development, allowing programmers to create reusable software
components. Objects allow programs to be organized in natural and intuitive
ways. This chapter presents the fundamentals of object-based programming, such
as encapsulation, data abstraction and abstract data types (ADTs). These
techniques hide the details of components so that the programmer can
concentrate on the "big picture." We create a
Time class, which
displays the time in standard and universal formats. We show how to create
reusable software components with assemblies, namespaces and Dynamic Link
Library (DLL) files. The reader will learn how to create classes and
namespaces. We discuss properties and the
readonly and
const keywords.
