Home > Store

C# How to Program

Register your product to gain access to bonus material or receive a coupon.

C# How to Program

Premium Website

  • Sorry, this book is no longer in print.
Not for Sale



  • Signature “Live-Code™ Approach”—Language features are presented in the context of a wide variety of complete working programs. Features thousands of lines of code in hundreds of complete working programs.
    • Enables students to confirm that programs run as expected. Students can also manipulate the code from the CD-ROM in the back of the book, from the book's Companion Website (www.prenhall.com/deitel), or from the authors' Website (www.deitel.com).

  • Outstanding, consistent and applied pedagogy—Icons throughout identify Software Engineering Observations; Good Programming Practices; Common Programming Errors; Portability Tips; Performance Tips, Testing and Debugging Tips, and Look-and-Feel Observations.
    • Provides hundreds of valuable programming tips and facilitates learning.

  • Extensive set of interesting exercises and substantial projects.
    • Students can apply what they've learned in each chapter.

  • Four-way syntax coloring with the use of two colors and shading.
    • Helps students better understand the book's hundreds of programs.

  • Also available with the Multimedia Cyber Classroom —In The Complete C# Training Course, Student Edition (CD-ROM version: 0-13-064586-9; Web-based version: 0-13-064762-4).
    • Provides extra hands-on experience and study aids for a minimal additional cost. Includes many hours of detailed, expert audio walkthroughs of the book's hundreds of live-code examples; post-assessment exams with hundreds of short-answer questions (all with answers); hundreds of self-review exercises drawn from the text (all with answers); hundreds of programming exercises from the main text (these exercises don't have answers in the main text, but half of these exercises have answers in The Complete Training Course); hundreds of tips that are marked with icons and show how to write C# code that's portable, reusable, and optimized for performance; and full-text searching and hyperlinking.

Each How to Program text can be ordered as a Complete Training Course package, containing the main text and the corresponding Cyber Classroom—an interactive, multimedia, tutorial version of the book. The Complete Training Courses are a great value, giving students extra hands-on experience and study aids for a minimal additional cost.

Each Complete Training Course is compatible with Windows 95, Windows 98, Windows NT and Windows 2000 and includes the following features:

  • The full text, illustrations and program listings of its corresponding How to Program book with full-text searching and hyperlinking.
  • Hours of detailed, expert audio descriptions of thousands of lines of code that help to reinforce concepts.
  • An abundance of self-assessment material:
    • Practice exams that offer students hundreds of short-answer test questions and answers.

    • Hundreds of self-review questions that are drawn from the text, all with answers.

    • Hundreds of programming exercises that are drawn from the text, half with answers (the main text does not provide any answers to these exercises).

  • Intuitive browser-based interface, designed to be easy and accessible for anyone who's ever used a Web browser.

We offer the Complete Training Courses in either a CD-ROM or a Web-based format. When professors order the Web-based version of a Complete Training Course, their students receive the corresponding How to Program book packaged with a URL and password that gives them six months of access to the Cyber Classroom software via the Web.

If your customer has already received C# How to Program, please sample only the C# Multimedia Cyber Classroom CD-ROM (0-13-064587-7) to show them the advantages they would get with The Complete Training Course. Please do not sample The Complete Training Course as they will receive a duplicate copy of the main text.


  • Copyright 2002
  • Edition: 1st
  • Premium Website
  • ISBN-10: 0-13-062221-4
  • ISBN-13: 978-0-13-062221-1

The authoritative DEITEL LIVE-CODE introduction to Windows®, .NET, Internet and World Wide Web programming in C#

This new book by the world's leading programming-language textbook authors carefully explains how to use C#—the premier language in Microsoft's .NET initiative—as a general-purpose programming language, and how to develop multi-tier, client/server, data-base-intensive, Internet- and Web-based applications.

Dr. Harvey M. Deitel and Paul J. Deitel are the founders of Deitel & Associates, Inc., the internationally-recognized corporate-training and content-creation organization specializing in C#, Visual Basic® .NET, Visual C++® .NET, Java, C++, C, XML, Python, Perl; Internet, Web, wireless, e-business and object technologies. The Deitels are the authors of several worldwide #1 programming-language textbooks, including Java How to Program, 4/e, C++ How to Program, 3/e and Internet & World Wide Web How to Program, 2/e.

In C# How to Program the Deitels and their colleagues, Jeff Listfield, Tem. R. Nieto, Cheryl Yaeger and Marina Zlatkina, discuss topics you need to build complete .NET, Web-based applications. Key topics include:

  • .NET Introduction/IDE/Debugger
  • Web Services/ASP.NET
  • Control Structures/Methods/Properties
  • Classes/Data Abstraction
  • OOP/Inheritance/Polymorphism
  • Arrays/Data Structures/Collections
  • Database/ADO .NET/SQL
  • Assemblies/Namespaces/Exceptions
  • GUI/Forms/Controls/Events/Delegates
  • Web Forms/Web Controls/Accessibility
  • Multithreading/Networking/Client-Server
  • Files/Streams/Strings/Regular Expressions
  • Operator Overloading/COM Integration
  • Multimedia/Graphics/GDI+
  • Bit and Character Manipulation/Unicode®

C# How to Program includes extensive pedagogic features:

  • Hundreds of LIVE-CODE programs with screen captures that show exact outputs
  • Internet and World Wide Web resources to encourage further research
  • Hundreds of tips, recommended practices and cautions—all marked with icons

C# How to Program is the centerpiece of a complete family of resources for teaching and learning C#, including several Web sites (www.deitel.com, www.prenhall.com/deitel and www.InformIT.com/deitel) with the book's source-code examples (which are also on the enclosed CD) and other information for faculty, students and professionals; an optional interactive CD (C# Multimedia Cyber Classroom) containing hyperlinks, solutions to half the book's exercises and audio walkthroughs of the book's code examples; and e-mail access to the authors at:

For information on worldwide Deitel on-site seminars and to subscribe to the Deitel Buzz e-mail newsletter, visit:

Sample Content

Table of Contents

(NOTE: Each chapter begins with an Introduction.

1. Introduction to Computers, Internet, World Wide Web and C#.

What Is a Computer? Computer Organization. Evolution of Operating Systems. Personal Computing, Distributed Computing and Client/Server Computing. Machine Languages, Assembly Languages and High-Leel Languages. C, CC++, Visual Basic .NET and Java™. C#. Other High-level Languages. Structured Programming. Key Software Trends: Object Technology. Hardware Trends. History of the Internet and World Wide Web. World Wide Web Consortium (W3C). Extensible Markup Language (XML). Introduction to Microsoft .NET. .NET Framework and the Common Language Runtime. Tour of the Book. Internet and World Wide Web Resources.

2. Introduction to the Visual Studio .NET IDE.

Visual Studio .NET Integrated Development Environment (IDE) Overview. Menu Bar and Toolbar. Visual Studio. .NET Windows. Using Help. Simple Program: Displaying Text and an Image.

3. Introduction to C# Programming.

Simple Program: Printing a Line of Text. Another Simple Program: Adding Integers. Memory Concepts. Arithmetic. Decision Making: Equality and Relational Operations.

4. Control Structures: Part 1.

Algorithms. Pseudocode. Control Structures. if Selection Structure. if/else Selection Structure. while Repetition Structure. Formulating Algorithms: Case Study 1 (Counter-Controlled Repetition). Formulating Algorithms with Top-Down, Stepwise Refinement: Case Study 3 (Nested Control Structures). Assignment Operators. Increment and Decrement Operators. Introduction to Widows Application Programming.

5. Control Structures: Part 2.

Essentials of Counter-Controlled Repetition. for Repetition Structure. Examples Using the for Structure. switch Multiple-Selection Structure. do/while Repetition Structure. Statements break and continue. Logical and Conditional Operators. Structured-Programming Summary.

6. Methods.

Program Modules in C#. Math Class Methods.Methods. Method Definitions. Argument Promotion. C# Namespaces. Value Types and Reference Types. Passing Arguments: Pass-by-Value vs. Passby-by-Reference. Random-Number Generation. Example: Game of Chance. Duration of Variables. Scope Rules. Recursion. Example Using Recursion: The Fibonacci Series. Recursion vs. Iteration. Method Overloading.

7. Arrays.

Declaring and Allocating Arrays. Examples Using Arrays. Passing Arrays to Methods. Passing Arrays by Value and Reference. Sorting Arrays. Searching Arrays: Linear Search and Binary Search. Multidimensional Rectangular and Jagged Arrays. Variable-Length Parameter Lists. For Each/Next Repetition Structure.

8. Object-Based Programming.

Implementing a Time Abstract Data Type with a Class. Class Scope. Controlling Access to Members. Initializing Class Objects: Constructors. Using Overloaded Constructors. Using Overloaded Construction. Properties. Composition: Objects References as Instance Variables of Other Classes. Using the this Reference. Garbage Collection. static Class Members. const and ReadOnly Members. Indexers Data Abstraction and Information Hiding. Software Reusability. Namespaces and Assemblies. Class View and Object Browser.

9. Object-Oriented Programming: Inheritance.

Base Classes and Derived Classes. protected and internal Members. Relationship between Base Classes and Derived Classes. Case Study: Three-Level Inheritance Hierarchy. Constructors and Destructors in Derived Classes. Software Engineering with Inheritance.

10. Object-Oriented Programming: Polymorphism.

Derived-Class-Object to Base-Class-Object Conversion. Type Fields and switch Statements. Polymorphism Examples. Abstract Classes and Methods. Case Study: Inheriting Interface and Implementation. sealed Classes and Methods. Case Study: Payroll System Using Polymorphism. Case Study: Crating and Using Interfaces. Delegates.

11. Exception Handling.

exception Handling Overview. Example: DivideByAZeroException. .NET Exception Hierarchy. Final Block. Exception Properties. Programmer-Defined Exception Classes. Handling Overflows.

12. Graphical User Interface Programming: Part 1.

Window Forms. Event-Handling Model. Control Properties and Layout. Labels, TextBoxes and Buttons. GroupBoxes and Panels. CheckBoxes and RadioButtons. PictureBoxes. Mouse-Event Handling. Keyboard-Event Handling.

13. Graphical User Interface Programming: Part 2.

Menus. LinkLabels. ListBoxes and CheckedListBoxes. ComboBoxes. TreeViews. ListViews. Tab Control. Multiple-Document-Interface (MDI) Windows. Visual Inheritance. User-Defined Controls.

14. Multithreading.

Thread States: Life Cycle of a Thread. Thread Priorities and Thread Scheduling. Thread Synchronization and Class Monitor. Producer/Consumer Relationship without Thread Synchronization. Producer/Consumer Relationship with Thread Synchronization. Producer/Consumer Relationship: Circular Buffer.

15. Strings, Characters and Regular Expressions.

Fundamentals of Characters and Strings. String Constructors. StringLength and Chars Properties, and CopyTo Method. Comparing Strings. String Method GetHashCode. Locating Characters and Substrings in Strings. Extracting Substrings from Strings. Concatenating Strings. Miscellaneous String Methods. Class StringBuilder. StringBuilder Indexer, Length and Capacity Properties, and EnsureCapacity Method. StringBuilderAppend and AppendFormat Methods. Char Methods. Chard Scuffling and Dealing Simulation. Regular Expressions and lass Regex.

16. Graphics and Multimedia.

Graphics Contexts and Graphics Objects. Color Control Font Control. Drawing Lines, Rectangles and Ovals. Drawing Arcs. Drawing Polygons and Polylines. Advanced Graphics Capabilities. Introduction to Multimedia. Loading, Displaying and Scaling Images. Animating a Series of Images. Windows Media Player. Microsoft Agent.

17. Files and Streams.

Data Hierarchy. Files and Streams. Classes Files and Directory. Creating a Sequential-Access File. Reading Data Sequentially from a Random-Access File. Case Study: A Transaction-Processing Program.

18. Extensible Markup Language (XML).

XML Documents. XZML Namespaces. Document Object Model (DOM). Document Type Definitions (DTDs), Schemas and Validation. Extensible Stylesheet Language and XslTransform.Microsoft BizTalk. Internet and World Wide Web Resources.

19. Database, SQL and ADO.NET.

Relational Database Model. Relational Database Overview: Books Database. Structured Query Language (SQL). ADO .NET Object Model. Programming with ADO .NET: Extracting Information from a DBMS. Prog4amming with ADO .NET: Modifying a DBMS. Reading and Writing XML Files.

20. ASP .NET, Web Forms and Web Controls.

Simple HTTP Transaction. System Architecture. Creating and Running a Simple Web Form Example. Web Controls. Session Tracking. Case Study: Online Guest Book. Case Study: Connecting to a Database in ASP .NET. Tracing. Internet and World Wide Web Resources.

21. ASP.NET and Web Services.

Web Services. Simple Object Access Protocol (SOAP) and Web Services. Publishing and Consuming Web Services. Session Tracking in Web Services. Using Web Forms and Web Services. Case Study: Temperature Information Application. User-Defined Types in Web Services.

22. Networking: Streams-Based Sockets and Datagrams.

Establishing a Simple Server (Using Stream Sockets). Establishing a Simple Client (Using Stream Sockets). Client/Server Interaction with Stream-Socket Connections. Connectionless Client/Server Interaction with Datagrams. Client/Server Tic-Tac-Toe Using a Multithreaded Server.

23. Data Structures and Collectors.

Self-Referential Classes. Linked Lists. Stacks. Queues. Trees. Collection Classes.

24. Accessibility.

Regulations and Resources. Web Accessibility Initiative. Proving Alternatives for Images. Maximizing Readability by Focusing on Structure. Accessibility in Visual Studio .NET. Accessibility in C#. Accessibility in XHTML Tables. Accessibility in XHTML Frames. Accessibility in XML. Using Voice Synthesis and Recognition with Voice XML™. CallXML™. JAWS® for Windows. Other Accessibility Tools. Accessibility in Microsoft® Windows® 2000. Internet and World Wide Web Resources.





Live in fragments no longer. Only connect.
Edward Morgan Forster

We wove a web in childhood,
A web of sunny air.

Charlotte Brontë

Welcome to C# and the world of Windows, Internet and World-Wide-Web programming with Visual Studio and the .NET platform! This book is the second in our new .NET How to Program series, which presents various leading-edge computing technologies in the context of the .NET platform.

C# is the next phase in the evolution of C and C++ and was developed expressly for Microsoft's .NET platform. C# provides the features that are most important to programmers, such as object-oriented programming, strings, graphics, graphical-user-interface (GUI) components, exception handling, multithreading, multimedia (audio, images, animation and video), file processing, prepackaged data structures, database processing, Internet and World-Wide-Web-based client/server networking and distributed computing. The language is appropriate for implementing Internet- and World-Wide-Web-based applications that seamlessly integrate with PC-based applications.

The .NET platform offers powerful capabilities for software development and deployment, including independence from a specific language or platform. Rather than requiring developers to learn a new programming language, programmers can contribute to the same software project, but write code using any (or several) of the .NET languages (such as Visual Basic .NET, Visual C++ .NET, C# and others) with which they are most competent. In addition to providing language independence, .NET extends program portability by enabling .NET applications to reside on, and communicate across, multiple platforms—thus facilitating the delivery of Web services over the Internet. .NET enables Web-based applications to be distributed to consumer-electronic devices, such as cell phones and personal digital assistants, as well as to desktop computers. The capabilities that Microsoft has incorporated into the .NET platform create a new software-development paradigm that will increase programmer productivity and decrease development time.

New Features in C# How to Program

This edition contains many new features and enhancements, including:

  • Two-Color Presentation. This book is in two color. Two color enables readers to see sample outputs similar to how they would appear on a color monitor. Also, we syntax color the C# code similar to the way Visual Studio .NET colors the code in its editor window. Our syntax-coloring conventions are as follows:
    - comments
    - keywords
    - literal values
    - text, class, method and variable names
  • "Code Washing." This is our term for the process we use to format the programs in the book so that they have a carefully commented, open layout. The code appears in full color and grouped into small, well-documented pieces. This greatly improves code readability—an especially important goal for us, considering that this book contains approximately 23,500 lines of code.
  • Web Services and ASP.NET. Microsoft's .NET strategy embraces the Internet and Web as integral to the software development and deployment processes. Web services—a key technology in this strategy—enables information sharing, commerce and other interactions using standard Internet protocols and technologies, such as Hypertext Transfer Protocol (HTTP), Simple Object Access Protocol (SOAP) and Extensible Markup Language (XML). Web services enable programmers to package application functionality in a form that turns the Web into a library of reusable software components. In Chapter 21, ASP .NET and Web Services, we present a Web service that allows users to make airline seat reservations. In this example, a user accesses a Web page, chooses a seating option and submits the page to the Web server. The page then calls a Web service that checks seat availability. We also present information relating to Web services in Appendix P, Crystal Reports® for Visual Studio® .NET, which discusses popular reporting software for database-intensive Visual Basic .NET applications. Crystal Reports, which is integrated into Visual Studio .NET, provides the ability to expose a report as a Web service. The appendix provides introductory information and then directs readers to a walkthrough of this process on the Crystal Decisions Web site (www.crystaldecisions.com/net).
  • Web Forms, Web Controls and ASP.NET. Applications developers must be able to create robust, scalable Web-based applications. The .NET platform architecture supports such applications. Microsoft's .NET server-side technology, Active Server Pages (ASP) .NET, allows programmers to build Web documents that respond to client requests. To enable interactive Web pages, server-side programs process information users input into HTML forms. ASP .NET is a significant departure from previous versions of ASP, allowing developers to program Web-based applications using the powerful object-oriented languages of .NET. ASP .NET also provides enhanced visual programming capabilities, similar to those used in building Windows forms for desktop programs. Programmers can create Web pages visually, by dragging and dropping Web controls onto a Web form. Chapter 20, ASP .NET, Web Forms and Web Controls, introduces these powerful technologies.
  • Object-Oriented Programming. Object-oriented programming is the most widely employed technique for developing robust, reusable software, and C# offers enhanced object-oriented programming features. This text offers a rich presentation of object-oriented programming. Chapter 8, Object-Based Programming, introduces how to create classes and objects. These concepts are extended in Chapter 9, Object-Oriented Programming: Inheritance, which discusses how programmers can create new classes that "absorb" the capabilities of existing classes. Chapter 10, Object-Oriented Programming: Polymorphism—familiarizes the reader with the crucial concepts of polymorphism, abstract classes, concrete classes and interfaces, which facilitate powerful manipulations among objects belonging to an inheritance hierarchy.
  • XML. Use of Extensible Markup Language (XML) is exploding in the software-development industry, the e-business and e-commerce communities, and is pervasive throughout the .NET platform. Because XML is a platform-independent technology for describing data and for creating markup languages, XML's data portability integrates well with Visual Basic C#'s portable applications and services. Chapter 18, Extensible Markup Language (XML) introduces XML. In this chapter, we introduce basic XML markup and discuss the technologies such as DTDs and Schema, which are used to validate XML documents' contents. We also explain how to programmatically manipulate XML documents using the Document Object Model (DOM) and how to transform XML documents into other types of documents via Extensible Stylesheet Language Transformations (XSLT).
  • Multithreading. Computers enable us to perform many tasks in parallel (or concurrently), such as printing documents, downloading files from a network and surfing the Web. Multithreading is the technology through which programmers can develop applications that perform concurrent tasks. Historically, a computer has contained a single, expensive processor, which its operating system would share among all applications. Today, processors are becoming so inexpensive that it is possible to build affordable computers containing many processors that work in parallel—such computers are called multiprocessors. Multithreading is effective on both single-processor and multiprocessor systems. C#s multithreading capabilities make the platform and its related technologies better prepared to deal with today's sophisticated multimedia-intensive, database-intensive, network-based, multiprocessor-based, distributed applications. Chapter 14, Multithreading provides a detailed discussion of multithreading.
  • ADO. NET. Databases store vast amounts of information that individuals and organizations must access to conduct business. As an evolution of Microsoft's ActiveX Data Objects (ADO), ADO .NET represents a new approach for building applications that interact with databases. ADO .NET uses XML and an enhanced object model to provide developers with the tools they need to access and manipulate databases for large-scale, extensible, mission-critical multi-tier applications. Chapter 19, Database, SQL and ADO .NET, details the capabilities of ADO .NET and the Structured Query Language (SQL) to manipulate databases.
  • Visual Studio .NET Debugger. Debuggers are programs that help programmers find and correct logic errors in program code. Visual Studio .NET contains a powerful debugging tool that allows programmers to analyze their program line-byline as the program executes. In Appendix D, Visual Studio .NET Debugger, we explain how to use key debugger features, such as setting breakpoints and "watches," stepping into and out of procedures, and examining the procedure call stack.
  • COM (Component Object Model) Integration. Prior to the introduction of .NET, many organizations spent tremendous amounts of time and money creating reusable software components called COM components, which include ActiveX® controls and ActiveX DLLs (dynamic link libraries) for Windows applications. Visual Basic programmers traditionally have been the largest group of COM component users. In the appendix, COM Integration, we discuss some of the tools available in Visual Studio .NET for integrating these legacy components into .NET applications. This integration allows programmers to use existing sets of COM-based controls with .NET components.
  • XML Documentation. Documenting program code is crucial for software development, because different programmers often work on an application during the software's lifecycle, which usually includes multiple versions and can span many years. If programmers document software code and methods, other programmers working on the application can learn and understand the logic underlying the code, thus saving time and avoiding misunderstandings. To automate documenting programs, Visual Studio.NET provides an XML tool for C# programmers. Appendix E, XML Documentation, explains how a programmer can insert comments in the code, which produces a separate file providing the code documentation.
  • Career Opportunities. Appendix C, Career Opportunities, introduces career services available on the Internet. We explore online career services from both the employer's and employee's perspectives. We list many Web sites at which you can submit applications, search for jobs and review applicants (if you are interested in hiring someone). We also review services that build recruiting pages directly into e-businesses. One of our reviewers told us that he had used the Internet as a primary tool in a recent job search, and that this appendix would have helped him expand his search dramatically.
  • Unicode. As computer systems evolved worldwide, computer vendors developed numeric representations of character sets and special symbols for the local languages spoken in different countries. In some cases, different representations were developed for the same languages. Such disparate character sets hindered communication among computer systems. Visual Basic .NET supports the Unicode Standard (maintained by a non-profit organization called the Unicode Consortium), which maintains a single character set that specifies unique numeric values for characters and special symbols in most of the world's languages. This appendix discusses the standard, overviews the Unicode Consortium Web site (www.unicode.org) and presents a Visual Basic .NET application that displays "Welcome to Unicode!" in several languages.
  • XHTML. The World Wide Web Consortium (W3C) has declared HTML to be a legacy technology that will undergo no further development. HTML is being replaced by the Extensible Hypertext Markup Language (XHTML)—an XML-based technology that is rapidly becoming the standard for describing Web content. We use XHTML in Chapter 18, Extensible Markup Language (XML), and offer an introduction to the technology in Appendix J, Introduction to XHTML: Part 1, and Appendix K, Introduction to XHTML: Part 2. These appendices overview headers, images, lists, image maps and other features of this emerging markup language. (We also present a treatment of HTML in Appendices H and I, because ASP .NET, used in Chapters 20 and 21, generates HTML content).
  • Accessibility. Currently, although the World Wide Web has become an important part of many people's lives, the medium presents many challenges to people with disabilities. Individuals with hearing and visual impairments, in particular, have difficulty accessing multimedia-rich Web sites. In an attempt to improve this situation, the World Wide Web Consortium (W3C) launched the Web Accessibility Initiative (WAI), which provides guidelines for making Web sites accessible to people with disabilities. Chapter 24, Accessibility, describes these guidelines and highlights various products and services designed to improve the Web-browsing experiences of individuals with disabilities. For example, the chapter introduces VoiceXML and CallXML, two XML-based technologies for increasing the accessibility of Web-based content for people with visual impairments.
  • Bit Manipulation. Computers work with data in the form of binary digits, or bits, which can assume the values 1 or 0. Computer circuitry performs various simple bit manipulations, such as examining the value of a bit, setting the value of a bit and reversing a bit (from 1 to 0 or from 0 to 1). Operating systems, test-equipment, networking software and many other kinds of software require that programs communicate "directly with the hardware" by using bit manipulation. Appendix O, Bit Manipulation, overviews the bit manipulation capabilities that the .NET Framework provides.

Some Notes to Instructors

Students Enjoy Learning a Leading-Edge Language
Dr. Harvey M. Deitel taught introductory programming courses in universities for 20 years with an emphasis on developing clearly written, well-designed programs. Much of what is taught in these courses represents the basic principles of programming, concentrating on the effective use of data types, control structures, arrays and functions. Our experience has been that students handle the material. in this book in about the same way that they handle other introductory and intermediate programming courses. There is one noticeable difference, though: Students are highly motivated by the fact that they are learning a leading-edge language, C#, and a leading-edge programming paradigm (object-oriented programming) that will be immediately useful to them as they enter a business world in which the Internet and the World Wide Web have a massive prominence. This increases their enthusiasm for the material—which is essential when you consider that there is much more to learn in a C# course now that students must master both the base language and substantial class libraries as well. Although C# is a new language that may require programmers to revamp their skills, programmers will be motivated to do so because of the powerful range of capabilities that Microsoft is offering in its .NET initiative.

A World of Object Orientation
In the late 1990s, universities were still emphasizing procedural programming. The leading-edge courses were using object-oriented C++, but these courses generally mixed a substantial amount of procedural programming with object-oriented programming—something that C++ lets programmers do. Many instructors now are emphasizing a pure object-oriented programming approach. This book—the first edition of C# How to Program and the second text in our .NET series—takes a predominantly object-oriented approach because of the object orientation provided in C#.

Focus of the Book
Our goal was clear: Produce a Visual Basic.NET textbook for introductory university-level courses in computer programming aimed at students with little or no programming experience, yet offer the depth and the rigorous treatment of theory and practice demanded by both professionals and students in traditional, upper-level programming courses. To meet these objectives, we produced a comprehensive book that patiently teaches the principles of computer programming and of the Visual Basic .NET language, including control structures, object-oriented programming, Visual Basic .NET class libraries, graphical-user-interface concepts, event-driven programming and more. After mastering the material in this book, students will be well-prepared to program in Visual Basic .NET and to employ the capabilities of the .NET platform.

Multimedia-Intensive Communications
People want to communicate. Sure, they have been communicating since the dawn of civilization, but the potential for information exchange has increased dramatically with the evolution of various technologies. Until recently, even computer communications were limited mostly to digits, alphabetic characters and special characters. The current wave of communication technology involves the distribution of multimedia—people enjoy using applications that transmit color pictures, animations, voices, audio clips and even full-motion color video over the Internet. At some point, we will insist on three-dimensional, moving-image transmission.

There have been predictions that the Internet will eventually replace radio and television as we know them today. Similarly, it is not hard to imagine newspapers, magazines and books delivered to "the palm of your hand" (or even to special eyeglasses) via wireless communications. Many newspapers and magazines already offer Web-based versions, and some of these services have spread to the wireless world. When cellular phones were first introduced, they were large and cumbersome. Today, they are small devices that fit in our pockets, and many are Internet-enabled. Given the current rate of advancement, wireless technology soon could offer enhanced streaming-video and graphics-packed services, such as video conference calls and high-power, multi-player video games.

Teaching Approach
C# How to Program contains a rich collection of examples, exercises and projects drawn from many fields and designed to provide students with a chance to solve interesting, real-world problems. The code examples in this text have been tested on Windows 2000 and Windows XP. The book concentrates on the principles of good software engineering, and stresses program clarity. We are educators who teach edge-of-the-practice topics in industry classrooms worldwide. We avoid arcane terminology and syntax specifications in favor of teaching by example. The text emphasizes good pedagogy.

LIVE-CODE Teaching Approach
C# How to Program is loaded with numerous LIVE-CODE examples. This style exemplifies the way we teach and write about programming, as well as being the focus of our multimedia Cyber Classrooms and Web-based training courses. Each new concept is presented in the context of a complete, working example that is immediately followed by one or more windows showing the program's input/output dialog. We call this method of teaching and writing the LIVE-CODE Approach. We use programming languages to teach programming languages. Reading the examples in the text is much like entering and running them on a computer.

World Wide Web Access
All of the examples for C# How to Program (and our other publications) are available on the Internet as downloads from the following Web sites:

Registration is quick and easy and these downloads are free. We suggest downloading all the examples, then running each program as you read the corresponding text. Making changes to the examples and immediately see the effects of those changes—a great way to learn programming. Each set of instructions assumes that the user is running Windows 2000 or Windows XP and is using Microsoft's Internet Information Services (IIS). Additional setup instructions for Web servers and other software can be found at our Web sites along with the examples. Note: This is copyrighted material. Feel free to use it as you study, but you may not republish any portion of it in any form without explicit permission from Prentice Hall and the authors.

Visual Studio .NET, which includes C#, can be purchased and downloaded from Microsoft. Three different version of Visual Studio .NET are available—Enterprise, Professional and Academic. Visit developerstore.com/devstore/ for more details and to order. If you are a member of the Microsoft Developer Network, visit msdn.microsoft.com/default.asp.

Each chapter begins with objectives that inform students of what to expect and give them an opportunity, after reading the chapter, to determine whether they have met the intended goals. The objectives serve as confidence builders and as a source of positive reinforcement.

The chapter objectives are followed by sets of quotations. Some are humorous, some are philosophical and some offer interesting insights. We have found that students enjoy relating the quotations to the chapter material. Many of the quotations are worth a "second look" after you read each chapter.

The chapter outline enables students to approach the material in top-down fashion. Along with the chapter objectives, the outline helps students anticipate future topics and set a comfortable and effective learning pace.

Approximately 23,500 Lines of Code in 204 Example Programs (with Program Outputs)
We present C# features in the context of complete, working C# programs. The programs range in size from just a few lines of code to substantial examples containing several hundred lines of code. All examples are available on the CD that accompanies the book or as downloads from our Web site, www.deitel.com.

607 Illustrations/Figures
An abundance of charts, line drawings and program outputs is included. The discussion of control structures, for example, features carefully drawn flowcharts. Note: We do not teach flowcharting as a program-development tool, but we do use a brief, flowchart-oriented presentation to explain the precise operation of each C# control structure.

509 Programming Tips
We have included programming tips to help students focus on important aspects of program development. We highlight hundreds of these tips in the form of Good Programming Practices, Common Programming Errors, Testing and Debugging Tips, Performance Tips, Portability Tips, Software Engineering Observations and Look-and-Feel Observations. These tips and practices represent the best the authors have gleaned from a combined seven decades of programming and teaching experience. One of our students—a mathematics major—told us that she feels this approach is like the highlighting of axioms, theorems and corollaries in mathematics books; it provides a foundation on which to build good software.

  • 91 Good Programming Practices
    Good Programming Practices are tips that call attention to techniques that will help students produce better programs. When we teach introductory courses to nonprogrammers, we state that the "buzzword" for each course is "clarity," and we tell the students that we will highlight (in these Good Programming Practices) techniques for writing programs that are clearer, more understandable and more maintainable.
  • 165 Common Programming Errors
    Students learning a language—especially in their first programming course—tend to make certain kinds of errors frequently. Pointing out these Common Programming Errors reduces the likelihood that students will make the same mistakes. It also shortens long lines outside instructors' offices during office hours!
  • 44 Testing and Debugging Tips
    When we first designed this "tip type," we thought the tips would contain suggestions strictly for exposing bugs and removing them from programs. In fact, many of the tips describe aspects of C# that prevent "bugs" from getting into programs in the first place, thus simplifying the testing and debugging process.
  • 57 Performance Tips
    In our experience, teaching students to write clear and understandable programs is by far the most important goal for a first programming course. But students want to write programs that run the fastest, use the least memory, require the smallest number of keystrokes or dazzle in other ways. Students really care about performance and they want to know what they can do to "turbo charge" their programs. We have included 49 Performance Tips that highlight opportunities for improving program performance—making programs run faster or minimizing the amount of memory that they occupy.
  • 16 Portability Tips
    We include Portability Tips to help students write portable code and to provide insights on how C# achieves its high degree of portability.
  • 115 Software Engineering Observations
    The object-oriented programming paradigm necessitates a complete rethinking of the way we build software systems. C# is an effective language for achieving good software engineering. The Software Engineering Observations highlight architectural and design issues that affect the construction of software systems, especially large-scale systems. Much of what the student learns here will be useful in upper-level courses and in industry as the student begins to work with large, complex real-world systems.
  • 21 Look-and-Feel Observations
    We provide Look-and-Feel Observations to highlight graphical-user-interface conventions. These observations help students design attractive, user-friendly graphical user interfaces that conform to industry norms.

Summary (1277 Summary bullets)
Each chapter ends with additional pedagogical devices. We present a thorough, bullet-list-style summary of the chapter. On average, there are 39 summary bullets per chapter. This helps the students review and reinforce key concepts.

Terminology (2932 Terms)
We include an alphabetized list of the important terms defined in the chapter in a Terminology section. Again, this serves as further reinforcement. On average, there are 89 terms per chapter. Each term also appears in the index, so the student can locate terms and definitions quickly.

693 Self-Review Exercises and Answers (Count Includes Separate Parts)
Extensive self-review exercises and answers are included for self-study. These questions and answers give the student a chance to build confidence with the material and prepare for the regular exercises. Students should be encouraged to attempt all the self-review exercises and check their answers.

367 Exercises (Solutions in Instructor's Manual; Count Includes Separate Parts)
Each chapter concludes with a substantial set of exercises that involve simple recall of important terminology and concepts; writing individual C# statements; writing small portions of C# methods and classes; writing complete C# methods, classes and applications; and writing major projects. These exercises cover a wide variety of topics, enabling instructors to tailor their courses to the unique needs of their audiences and to vary course assignments each semester. Instructors can use the exercises to form homework assignments, short quizzes and major examinations. The solutions for the exercises are included in the Instructor's Manual and on the disks available only to instructors through their Prentice-Hall representatives. NOTE: Please do not write to us requesting the instructor's manual. Distribution of this publication is strictly limited to college professors teaching from the book. Instructors may obtain the solutions manual from their regular Prentice Hall representatives. We regret that we cannot provide the solutions to professionals. Solutions to approximately half the exercises are included on the C# Multimedia Cyber Classroom CD-ROM (available in April 2002 at www.InformIT.com/cyberclassrooms; also see the last few pages of this book or visit www.deitel.com for ordering instructions). Also available in April 2002 is the boxed product, The Complete C# Training Course, which includes both our textbook, C# How to Program and the C# Multimedia Cyber Classroom. All of our Complete Training Course products are available at bookstores and online booksellers, including www.InformIT.com.

Approximately 5,420 Index Entries (with approximately 6,750 Page References)
We have included an extensive Index at the back of the book. Using this resource, students can search for any term or concept by keyword. The Index is especially useful to practicing programmers who use the book as a reference. Each of the 2,932 terms in the Terminology sections appears in the Index (along with many more index items from each chapter). Students can use the index in conjunction with the Terminology sections to ensure that they have covered the key material in each chapter.

"Double Indexing" of All C# .NET LIVE-CODE Examples
C# How to Program has 204 LIVE-CODE examples, which we have "double indexed." For every C# source-code program in the book, we took the file name with the .cs extension, such as ChessGame.cs, and indexed it both alphabetically (in this case, under "C") and as a subindex item under "Examples." This makes it easier to find examples using particular features.

C# Multimedia Cyber Classroom, Second Edition and The Complete C# Training Course

We have prepared an interactive, CD-ROM-based, software version of C# How to Program called the C# Multimedia Cyber Classroom. This resource is loaded with e-Learning features that are ideal for both learning and reference. The Cyber Classroom is packaged with the textbook at a discount in The Complete C# Training Course. If you already have the book and would like to purchase the C# Multimedia Cyber Classroom separately, please visit www.InformIT.com/cyberclassrooms. The ISBN number for the Visual Basic .NET Multimedia Cyber Classroom, Second Edition, is 0-13-065193-1. All Deitel Cyber Classrooms are available in CD-ROM and Web-based training formats.

The CD provides an introduction in which the authors overview the Cyber Classroom's features. The textbook's 204 LIVE-CODE® example C# programs truly "come alive" in the Cyber Classroom. If you are viewing a program and want to execute it, you simply click the lightning-bolt icon, and the program will run. You immediately will see—and hear, when working with audio-based multimedia programs—the program's outputs. If you want to modify a program and see the effects of your changes, simply click the floppy-disk icon that causes the source code to be "lifted off' the CD and "dropped into" one of your own directories so you can edit the text, recompile the program and try out your new version. Click the audio icon, and one of the authors will discuss the program and "walk you through" the code.

The Cyber Classroom also provides navigational aids, including extensive hyperlinking. The Cyber Classroom is browser based, so it remembers sections that you have visited recently and allows you to move forward or backward among these sections. The thousands of index entries are hyperlinked to their text occurrences. Furthermore, when you key in a term using the "find" feature, the Cyber Classroom will locate occurrences of that term throughout the text. The Table of Contents entries are "hot," so clicking a chapter name takes you immediately to that chapter.

Students like the fact that solutions to approximately half the exercises in the book are included with the Cyber Classroom. Studying and running these extra programs is a great way for students to enhance their learning experience.

Students and professional users of our Cyber Classrooms tell us that they like the interactivity and that the Cyber Classroom is an effective reference due to its extensive hyperlinking and other navigational features. We received an email from a person who said that he lives "in the boonies" and cannot take a live course at a university, so the Cyber Classroom provided an ideal solution to his educational needs.

Professors tell us that their students enjoy using the Cyber Classroom and spend more time on the courses and master more of the material than in textbook-only courses. For a complete list of the available and forthcoming Cyber Classrooms and Complete Training Courses, see the Deitel® Series page at the beginning of this book, the product listing and ordering information at the end of this book or visit www.deitel.com, www.prenhall.com/deitel and www.InformIT.com/deitel.

Deitel e-Learning Initiatives

e-Books and Support for Wireless Devices
Wireless devices will play an enormous role in the future of the Internet. Given recent bandwidth enhancements and the emergence of 2.5 and 3G technologies, it is projected that, within two years, more people will access the Internet through wireless devices than through desktop computers. Deitel & Associates, Inc., is committed to wireless accessibility and has recently published Wireless Internet & Mobile Business How to Program. To fulfill the needs of a wide range of customers, we currently are developing our content both in traditional print formats and in newly developed electronic formats, such as e-books so that students and professors can access content virtually anytime, anywhere. Visit www.deitel.com for periodic updates on this initiative.

Deitel & Associates, Inc., is partnering with Prentice Hall's parent company, Pearson PLC, and its information technology Web site, www.InformIT.com, to launch the Deitel e-Matter series at www.InformIT.com/deitel. This series will provide professors, students and professionals with an additional source of information on specific programming topics. e-Matter consists of stand-alone sections taken from published texts, forthcoming texts or pieces written during the Deitel research-and-development process. Developing e-Matter based on pre-publication books allows us to offer significant amounts of the material to early adopters for use in courses. Some possible Visual Basic .NET e-Matter titles we are considering include Object-Based Programming and Object-Oriented Programming in Visual Basic.NET; Graphical User Interface Programming in Visual Basic.NET; Multithreading in Visual Basic .NET; ASP .NET and Web Forms: A Visual Basic .NET View; and ASP .NET and Web Services: A Visual Basic.NET View.

Course Management Systems: WebCT, Blackboard, and CourseCompass
We are working with Prentice Hall to integrate our How to Program Series courseware into three Course Management Systems: WebCT, Blackboard and CourseCompass. These Course Management Systems enable instructors to create, manage and use sophisticated Web-based educational programs. Course Management System features include course customization (such as posting contact information, policies, syllabi, announcements, assignments, grades, performance evaluations and progress tracking), class and student management tools, a gradebook, reporting tools, communication tools (such as chat rooms), a whiteboard, document sharing, bulletin boards and more. Instructors can use these products to communicate with their students, create online quizzes and tests from questions directly linked to the text and automatically grade and track test results. For more information about these upcoming products, visit www.deitel.com/whatsnew.html. For demonstrations of existing WebCT, Blackboard and CourseCompass courses, visit http://cms.prenhall.com/webct/index.html, http://cms.prenhall.com/blackboard/index.html, and http://cms.prenhall.com/coursecompass/index.html respectively.

Deitel and InformIT Newsletters

Deitel Column in the InformIT Newsletters
Deitel & Associates, Inc., contributes a weekly column to the popular InformIT newsletter, currently subscribed to by more than 800,000 IT professionals worldwide. For opt-in registration, visit www.InformIT.com

Deitel Newsletter
Our own free, opt-in newsletter includes commentary on industry trends and developments, links to articles and resources from our published books and upcoming publications, information on future publications, product-release schedules and more. For opt-in registration, visit www.deitel.com.

The Deitel .NET Series

Deitel & Associates, Inc., is making a major commitment to .NET programming through the launch of our.NET Series. Visual Basic.NET How to Program, Second Edition and C# .NET How to Program are the first books in this new series. We intend to follow these books with Advanced Visual Basic.NET How to Program and Advanced C#.NET How to Program, which will be published in December 2002. We also plan to publish Visual C++ .NET How to Program in July 2002, followed by Advanced Visual C++ .NET How to Program in July 2003.

Advanced C# How to Program

C# How to Program covers introductory through intermediate-level C# programming topics, as well as core programming fundamentals. By contrast, our upcoming textbook Advanced C# How to Program will be geared toward experienced C# developers. This new book will cover enterprise-level programming topics, including: Creating multi-tier, database intensive ASP.NET applications using ADO.NET and XML; constructing custom Windows controls; developing custom Web controls; and building Windows services. The book also will include more in-depth explanations of object-oriented programming (with the UML), ADO.NET, XML Web services, wireless programming and security. Advanced C# How to Program will be published in December 2002.


Submit Errata

More Information

Unlimited one-month access with your purchase
Free Safari Membership