C# FOR STUDENTS

DOUGLAS BELL AND MIKE PARR

WHY WE DID WHAT WE DID

About this book

For Instructors

More books by us

For Students

Contents

Preface

Sample Chapters

Download C# system, and code

Bonus Database Chapter

We tried to bear in mind that this is a first level book. We have therefore erred on the side of avoiding complexities.

This is a book about a language, obviously, but also about how to do programming in general. Hence the plan to avoid some of the details of the language. Plus we suspect that there is sufficient challenge in learning what we have included in the book - which we see as the important ideas in programming and in programming languages.

A number of reviewers looked at the book before it was published and made many eminently sensible and constructive suggestions. We thank them for their efforts in improving the book. We considered seriously, but didn't adopt all their suggestions. Some of the rationale is given below.

We hope you find the book useful and maybe even enjoyable.

3 Introductory Graphics

Our vision is that students would enjoy using graphics because of its immediate visual appeal and that graphics would be the vehicle for understanding a number of programming ideas.

In C#, there are two ways to do graphics:

1. a simple way, that we use in the book
2. the proper way, which is more complex. This involves knowledge of events, and of components re-painting themselves. We think this can confuse beginners, so we avoid it.

4 Variables and Calculations

We have restricted ourselves to just two of the shortcut operators, ++ and --. These are the most useful, particularly inside loops. We feel that the others are rarely used and can be more trouble than they are worth (to the novice).

7 Selection

We decided, for simplicity, to cover only the && || and ! operators. It seems to us that to introduce the others in a first level book is just too much.

In the section on nesting, we could have introduced if else (with a space between them) but, again, we decided that enough is enough

The McBurgers program could, of course, be done more concisely (without an if statement) using:

label1.Visible = ! label1.Visible;

but instead we did it the long way to avoid introducing another use for the ! operator.

10 Writing Classes

We made the decision to omit a treatment of structures. We think they detract from a straightforward account of classes - they are an unnecessary complication.

13 Data Structures

Readers can skip this chapter. But it is there to provide a gentle introduction to data structures. In our experience, students have difficulty in understanding arrays and array lists because they are invisible. But list boxes are visible. See this article for more of the argument.

You might care to use this material instead of the stuff on arrays.

15 Arrays - 2 dimensional

For simplicity (again) we have omitted treatment of jagged arrays.

19 Console Programs

The whole theme of the book is programs with a GUI. But we felt we should not neglect console programs. Some programs take the other approach and are all about console programs.

23 and 24 Interfaces and polymorphism

Some reviewers thought we should introduce these topics earlier - at the same time as the topic of inheritance, or immediately afterwards. But we think that these are rather more advanced topics and that is why we put them at the end. We suspect that readers have enough on to understand the ideas of writing a class and then the idea of inheritance without having to immediately address the concepts of interfaces and polymorphism