SKIP THE SHIPPING
Use code NOSHIP during checkout to save 40% on eligible eBooks, now through January 5. Shop now.
Register your product to gain access to bonus material or receive a coupon.
Enables students to utilize limited study time as effectively as possible, by leveraging the knowledge they already have.
Gives students the benefit of pedagogical methods that have helped over a million developers learn rapidly and well.
Makes it exceptionally easy for students to understand and learn from the books code examples.
Helps students become effective C# .NET developers as quickly as possible.
Helps students master C# programming techniques with exceptional power and broad applicability.
Helps students master Web services, an area of development that is expected to remain in exceptionally high demand for years to come.
Prepares students to develop Web applications for wireless phones, pagers, PDAs, and other wireless devices—one of the fastest growing areas of Web development.
Gives students confidence that they are receiving information that is thorough, accurate, clear, and pedagogically proven.
The practicing programmer's DEITEL LIVE-CODE guide toC# and the powerful Microsoft .NET Framework.
C# for Experienced Programmers is written for programmers with backgrounds in C++, Visual Basic, Java or other high-level languages, who want to learn C# through the intermediate level. If you already own C# How To Program, 1/e, you should not purchase C# for Experienced Programmers. However, you may be interested in our ASP .NET with C# for Experienced Programmers, which will be published in Summer 2003. Students should not purchase C# for Experienced Programmers. Instead, students should purchase C# How To Program, 1/e, as it contains self-review exercises and other ancillary materials suitable for self-study and classroom use. We also recommend that everyone consider The Complete C# Training Course, 1/e, which includes C# How to Program, 1/e and the C# Cyber Classroom--an interactive, multimedia, Windows-based CD-ROM. The Complete Training Course offers a great value and provides a powerful learning tool for readers who want to pursue C# programming through the intermediate level.
Written for programmers with a background in C++, Visual Basic, Java or other high-level languages, this book applies the DEITEL signature LIVE-CODE approach to teaching programming and explores Microsoft's C# language in depth. This book presents important C# concepts in the context of fully tested programs, complete with syntax shading, detailed line-by-line descriptions and program outputs. The book features 230 LIVE-CODE programs that contain 26,006 lines of proven C# program code. In addition, the book includes 402 programming tips that help you build applications that are portable, reusable and optimized for performance.
Start with a concise introduction to C # fundamentals, then rapidly move on to more advanced topics, including Windows Forms, ADO .NET, ASP .NET, ASP .NET Web services, network programming and XML processing. Along the way you will enjoy the Deitels' classic treatment of object-based and object-oriented programming. When you are finished, you will have everything you need to build next-generation Windows applications, Web applications and XML Web services.
Dr. Harvey M. Deitel and Paul J. Deitel are the founders of Deitel & Associates, Inc., the internationally recognized IT content-creation and corporate-training organization. Together with their colleagues at Deitel & Associates, Inc., they have written the successful How to Program Series of college textbooks that hundreds of thousands of students throughout the world have used to master C, C++, Java, C#, Visual Basic .NET, Perl, Python, XML, and other languages.The DEITEL Developer Series is designed for practicing programmers. The series presents focused treatments of emerging technologies, including .NET, J2EE, Web services, and more. Each book in the series contains the same LIVE-CODE teaching methodology used so successfully in the Deitels' How to Program Series college textbooks and instructor-led, corporate-training courses. The DEITEL Developer Series includes a wide selection of books suitable for three types of readers:A Technical IntroductionBroad overviews of new technologies for programmers, technical managers and other technical professionalsA Programmer's Introduction Focused treatments of programming fundamentals for practicing programmers and for novicesFor Experienced Programmers Detailed treatments of language topics for experienced programmersDEITEL TESTIMONIALS"Your book has sparked a passion in me for programming like no other."
Scott Haynes
"Comprehensive, coherent, clear, and just plain FUN to work through!"
James Huddleston
"I must say my favorite feature is the examples..."
Ben Schrooten
"I have read many books and taken many training courses over the past 20 years, but this stands out as the absolute best!"
Cindy Steele
Preface.
1. Introduction to .NET and C#.
2. Introduction to the Visual Studio .NET IDE and C# Programming.
3. Control Structures.
4. Methods and Arrays.
5. Object-Based Programming.
6. Object-Oriented Programming: Inheritance.
7. Object-Oriented Programming: Polymorphism.
8. Exception Handling.
9. Graphical User Interface Concepts: Part 1.
10. Graphical User Interface Concepts: Part 2.
11. Multithreading.
12. Strings, Characters and Regular Expressions.
13. Graphics and Multimedia.
14. Files and Streams.
15. Extensible Markup Language (XML).
16. Database, SQL and ADO .NET.
17. ASP .NET, Web Forms and Web Controls.
18. ASP .NET and Web Services.
19. Networking: Streams-Based Sockets and Datagrams.
20. Data Structures and Collections.
21. Accessibility.
22. Mobile Internet Toolkit.
Appendix A. Operator Precedence Chart.
Appendix B. Number Systems.
Appendix C. Career Opportunities.
Appendix D. Visual Studio .NET Debugger.
Appendix E. Generating Documentation in Visual Studio .NET.
Appendix F. ASCII Character Set.
Appendix G. Unicode®.
Appendix H. COM Integration.
Appendix I. Introduction to HyperText Markup Language 4: Part 1.
Appendix J. Introduction to HyperText Markup Language 4: Part 2.
Appendix K. Introduction to XHTML: Part 1.
Appendix L. Introduction to XHTML: Part 2.
Appendix M. HTML/XHTML Special Characters.
Appendix N. HTML/XHTML Colors.
Appendix O. Bit Manipulation.
Appendix P. Crystal Reports® for Visual Studio .NET.
Bibliography.
Index.
Live in fragments no longer. Only connect.
Edward Morgan Forster
We wove a web in childhood,
A web of sunny air.
Charlotte Bronte
Welcome to C# and the world of Windows, Internet and World-Wide-Web programming with Visual Studio .NET and the .NET platform! This book is the second in the new Deitel Developer Series, which presents leading-edge computing technologies to software developers and IT professionals.
C# (pronounced "C-sharp") was developed by Microsoft expressly for its .NET platform. C# provides the features that are most important to programmers, such as object-oriented programming, 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 multi-tier application development, networking, Web services and distributed computing. The language is appropriate for implementing Internet- and World-Wide-Web-based applications that integrate seamlessly with Windows-based applications.
The .NET platform offers powerful capabilities for software development and deployment, including language and platform independence. For example, developers writing code in any (or several) of the .NET languages (such as C#, Visual Basic .NET and Visual C++ .NET) can contribute components to the same software product. In addition to providing language independence, .NET extends program portability by enabling .NET applications to reside on, and communicate across, multiple platforms. This facilitates the creation and use of Web services, which are applications that expose functionality to clients via the Internet.
The .NET platform enables Web-based applications to be distributed to consumer-electronic devices, such as wireless phones and personal digital assistants (PDAs), as well as to desktop computers. The capabilities that Microsoft has incorporated into the .NET platform increase programmer productivity and decrease development time.
Deitel & Associates, Inc. has several C# publications, intended for various audiences. We provide information on www.deitel.com
, here and inside this book's back cover to help you determine which publication is best for you.
Our first C# book, C# How to Program, was published as part of our How to Program Series, for college and university students. It provides a comprehensive treatment of C# and includes learning aids and extensive ancillary support. C# How to Program assumes that the reader has little or no programming experience. Early chapters focus on fundamental programming principles. The book builds on this to create increasingly complex and sophisticated programs that demonstrate how to use C# to create graphical user interfaces, networking applications, multithreaded applications, Web-based applications and more. We encourage professors and professionals to consider the C# Complete Training Course. This package includes C# How to Program as well as the C# Multimedia Cyber Classroom, an interactive multimedia CD-ROM that provides extensive e-Learning features. The C# Complete Training Course and C# Multimedia Cyber Classroom are discussed in detail later in this Preface.
Our third C# publication, C#: A Programmer's Introduction, is part of the new Deitel Developer Series, intended for professional software developers-from novices through experienced programmers. C#: A Programmer's Introduction is a part of the A Programmer's Introduction subseries, which is designed for programmers with little (or no) programming experience. The book begins with C# programming fundamentals. The core of C#: A Programmer's Introduction emphasizes achieving program clarity through the proven techniques of structured programming, object-based programming, object-oriented programming (OOP) and event-driven programming. The book provides a rigorous introduction to programming principles in general and to C# fundamentals, in particular. It continues with brief introductions to upper-level topics such as ASP .NET, ADO .NET, and Web services. Unlike the How to Program Series books, the Deitel Developer Series books do not include the extensive pedagogic features and ancillary support materials required for academic courses.
This book, C# for Experienced Programmers, is also part of the Deitel Developer Series. This publication is a part of the For Experienced Programmers subseries, designed for the experienced software developer who wants a deep treatment of a new technology with minimal, if any, introductory material. C# for Experienced Programmers delves deeply into the more sophisticated topics that are introduced briefly in C#: A Programmer's Introduction. There is considerable overlap between these books.
A fourth publication, ASP .NET with C# for Experienced Programmers, is forthcoming. This book was originally titled Advanced C# for Experienced Programmers.
Each of our C# books presents many complete, working C# programs and depicts their inputs and outputs in actual screen shots of running programs. This is our signature Live-Code approachwe present all concepts in the context of complete working programs. Each book's source code is available free for download at www.deitel.com
.
Please examine both the Deitel Developer Series professional books and the How to Program Series textbooks to determine which best suits your needs. C#: A Programmer's Introduction and C# for Experienced Programmers are both derived from C# How to Program. Depending on your particular needs, you should purchase either one or both of these Deitel Developer Series books, or C# How to Program.
The C# books in the Deitel Developer Series were written after the first edition of C# How to Program. We added to each of these Deitel Developer Series books a chapter on the new Microsoft Mobile Internet Toolkit for our readers who wish to develop wireless Internet applications for cell phones, pagers and PDAs. This material will be added to the second edition of C# How to Program.
For a detailed listing of Deitel products and services, please see the "advertorial" pages at the back of this book and visit www.deitel.com
. Readers may also want to register for our new Deitel Buzz Online e-mail newsletter (www.deitel.net/newsletter/subscribe.html
), which provides information about our publications, company announcements, links to informative technical articles, programming tips, teaching tips, challenges and anecdotes.
As you proceed, if you would like to communicate with us, please send an e-mail to deitel@deitel.com
we always respond promptly. Please check our Web sites, www.deitel.com
, www.prenhall.com/deitel
and www.InformIT.com/deitel
for frequent updates, errata, FAQs, etc. When sending an e-mail, please include the book's title and edition number. We sincerely hope that you enjoy learning C# with our publications.
This edition contains many features, including:
www.crystaldecisions.com/netzone
C# for Experienced Programmers contains a rich collection of examples that 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.
We use fonts to distinguish between Visual Studio .NET's Integrated Development Environment (IDE) features (such as menu names and menu items) and other elements that appear in the IDE. Our convention is to emphasize IDE features in a sans-serif bold Helvetica font (e.g., Project menu) and to emphasize program text in a serif bold Courier font (e.g., bool x = true;).
C# for Experienced Programmers is loaded with numerous Live-Code examples. This style exemplifies the way we teach and write about programming and is the focus of our multimedia Cyber Classrooms and Web-based training courses as well. Each new concept is presented in the context of a complete, working example that is 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. Readers have the option of downloading all of the book's code examples from www.deitel.com
, under the Downloads/Resources link. Other links provide errata and answers to frequently asked questions.
All of the source code for the examples in C# for Experienced Programmers (and our other publications) is available on the Internet as downloads from the following Web sites:
www.deitel.comwww.prenhall.com/deitel
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 portion of the book. Make changes to the examples and immediately see the effects of those changes-this is a great way to improve your programming skills. Any instructions for running the examples assumes that the user is running Windows 2000 or Windows XP and is using Microsoft's Internet Information Services (IIS). Additional setup instructions for IIS 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 Pearson and the authors.
Visual Studio .NET belongs to a family of products that are available for purchase and download from Microsoft. Visual Studio .NET, which includes C#, comes in four different editions-Academic, Professional, Enterprise Developer and Enterprise Architect. Visual Studio .NET Academic contains Visual Studio .NET Professional's features in addition to features designed for students and professors (e.g., an Assignment Manager that documents assignment submission, Application Publishing Tools that aid in the notification of assignments, code samples and more).
Microsoft also offers stand-alone products (Visual C# .NET Standard, Visual C++ .NET Standard and Visual Basic .NET Standard) for various .NET-languages. Each product provides an integrated development environment (similar to Visual Studio .NET) and a compiler. Visit msdn.microsoft.com/vstudio/howtobuy
for descriptions and ordering information.
Each chapter begins with objectives that inform readers of what to expect and gives them an opportunity, after reading the chapter, to determine whether they have met the intended goals.
The chapter objectives are followed by sets of quotations. Some are humorous, some are philosophical and some offer interesting insights. We have found that readers 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 readers to approach the material in top-down fashion. Along with the chapter objectives, the outline helps users anticipate topics and set a comfortable and effective learning pace.
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 hundreds of lines of code. All examples are available as downloads from our Web site, www.deitel.com.
An abundance of charts, line drawings and program outputs is included.
We have included programming tips to help readers 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 many decades of programming and teaching experience. One of our customersQa mathematics majorQtold 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.
Good Programming Practices are tips that call attention to techniques that will help developers produce programs that are clearer, more understandable and more maintainable.
Developers learning a language tend to make certain kinds of errors frequently. Pointing out these Common Programming Errors reduces the likelihood that readers will make the same mistakes.
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 processes.
Developers like to "turbo charge" their programs. We have included 29 Performance Tips that highlight opportunities for improving program performance-making programs run faster or minimizing the amount of memory that they occupy.
We include Portability Tips to help developers write portable code and to provide insights on how C# achieves its high degree of portability.
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.
We provide Look-and-Feel Observations to highlight graphical-user-interface conventions. These observations help developers design attractive, user-friendly graphical user interfaces that conform to industry norms.
Each chapter ends with a summary that helps readers review and reinforce key concepts.
We have included an extensive Index. This resource enables readers to search for any term or concept by keyword. The Index is especially useful to practicing programmers who use the book as a reference.
C# for Experienced Programmers has 152 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 ShowColors.cs, and indexed it both alphabetically (in this case, under "S") and as a subindex item under "Examples." This makes it easier to find examples using particular features.
We have prepared an interactive, CD-ROM-based, software version of C# How to Program, called the C# Multimedia Cyber Classroom. This resource, ideal for corporate training and college courses, is loaded with interactive e-learning features. The Cyber Classroom is packaged with the C# How to Program textbook at a discount in The Complete C# Training Course. If you already have that book and would like to purchase the C# Multimedia Cyber Classroom separately, please visit www.InformIT.com/cyberclassrooms
. The ISBN number for the C# Multimedia Cyber Classroom is 0-13-064587-7. Many Deitel Cyber Classrooms are available in CD-ROM and Web-based training formats.
The CD-ROM 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 output. 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 those 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.
Readers like the fact that solutions to approximately half the exercises in C# How to Program are included with the Cyber Classroom. Studying and running these extra programs is a great way for readers to enhance their learning experience.
Professionals and student 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 e-mail from a reader who said he lives "in the boonies" and cannot attend 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 or www.InformIT.com/deitel.
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 wireless 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 are developing our content in traditional print formats and in new electronic formats, such as e-books, so that readers can access content virtually anytime, anywhere. Visit www.deitel.com
for periodic updates on all Deitel technology initiatives.
Deitel & Associates, Inc. is partnering with Prentice Hall's parent company, Pearson PLC, and its information technology Web site, InformIT.com, to launch the Deitel e-Matter series at www.InformIT.com/deitel
in Fall 2002. The Deitel e-Matter series will provide professionals with an additional source of information on specific programming topics at modest prices. 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 manuscripts allows us to offer significant amounts of the material well before our books are published.
We are working with Prentice Hall to integrate our How to Program Series courseware into four Course Management Systems: WebCT, Blackboard, CourseCompass and Premium CourseCompass. These enable instructors to create, manage and use sophisticated Web-based educational programs. Course Management Systems feature course customization (such as posting contact information, policies, syllabi, announcements, assignments, grades, performance evaluations and progress tracking), class and student management tools, a grade book, 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 exams from questions directly linked to the text and efficiently grade and track test results. For more information about these upcoming products, visit www.prenhall.com/cms. For demonstrations of existing WebCT, Blackboard and CourseCompass course materials, visit cms.prenhall.com/webct
, cms.prenhall.com/blackboard
and cms.prenhall.com/coursecompass
, respectively.
Deitel & Associates, Inc., contributes articles to the free InformIT weekly e-mail newsletter, subscribed to by more than 750,000 IT professionals worldwide. For registration information, visit www.InformIT.com
and click the MyInformIT tab.
Our own free newsletter, the Deitel Buzz Online, includes commentary on industry trends and developments, links to articles and resources from our published books and upcoming publications, product-release schedules, challenges, anecdotes and more. For registration information, visit www.deitel.com/newsletter/subscribe.html
Deitel & Associates, Inc., is making a major commitment to .NET programming through the launch of our Deitel? Developer Series. C#: A Programmer's Introduction, C# for Experienced Programmers, Visual Basic .NET for Experienced Programmers and Visual C++ .NET for Experienced Programmers are the first .NET books in this new series. These will be followed by several advanced books, beginning with ASP .NET with Visual Basic .NET for Experienced Programmers and ASP .NET with C# for Experienced Programmers.
The Deitel Developer Series is divided into three subseries. The A Technical Introduction subseries provides IT managers and developers with detailed overviews of emerging technologies. The A Programmer's Introduction subseries is designed to teach the fundamentals of new languages and software technologies to developers from the ground up. These books discuss programming fundamentals, followed by brief introductions to more sophisticated topics. Finally, the For Experienced Programmers subseries is designed for seasoned developers seeking to learn new programming languages and technologies without the encumbrance of introductory material. The books in this subseries move quickly to in-depth coverage of the intermediate features of the programming languages and software technologies being covered.
Our forthcoming publication ASP .NET with C# for Experienced Programmers (available in 2003) is geared toward experienced .NET developers. This new book will cover enterprise-level Web-programming topics, including: Creating multi-tier, database intensive ASP .NET applications using ADO .NET and XML; constructing custom Web controls and developing Web services. This book also will include configuration and security topics. Updates on the status of this publication are posted at www.deitel.com. Before reading this book you should be familiar with C# at the level of either C# How to Program or C# for Experienced Programmers.
We would sincerely appreciate your comments, criticisms, corrections and suggestions for improving the book. Please address all correspondence to:
deitel@deitel.com
We will respond promptly.
Well, that's it for now. Welcome to the exciting world of C# programming. We hope you enjoy this introductory look at Microsoft's premier .NET language. Good luck!
Dr. Harvey M. Deitel
Paul J. Deitel
Jeff Listfield
Tem R. Nieto
Cheryl H. Yaeger
Marina Zlatkina