Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Tài liệu đang bị lỗi
File tài liệu này hiện đang bị hỏng, chúng tôi đang cố gắng khắc phục.
Tài liệu BEGINNING OBJECT-ORIENTED PROGRAMMING WITH C# doc
Nội dung xem thử
Mô tả chi tiết
ffirs.indd iv ffirs.indd iv 10/8/2012 8:54:40 AM 10/8/2012 8:54:40 AM
BEGINNING
OBJECT-ORIENTED PROGRAMMING WITH C#
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxv
PART I GETTING STARTED
CHAPTER 1 Introducing C# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
CHAPTER 2 Understanding Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19
PART II UNDERSTANDING C# SYNTAX
CHAPTER 3 Understanding Data Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
CHAPTER 4 Understanding C# Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81
CHAPTER 5 Understanding Reference Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
CHAPTER 6 Making Decisions in Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .147
CHAPTER 7 Statement Repetition Using Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
CHAPTER 8 Understanding Arrays and Collections . . . . . . . . . . . . . . . . . . . . . . . . . . 193
PART III WRITING YOUR OWN CLASSES
CHAPTER 9 Designing Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
CHAPTER 10 Designing and Writing Custom Classes . . . . . . . . . . . . . . . . . . . . . . . . . . 255
CHAPTER 11 Exception Handling and Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
CHAPTER 12 Generics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
PART IV STORING DATA
CHAPTER 13 Using Disk Data Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
CHAPTER 14 Using Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
CHAPTER 15 Using LINQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
Continues
ffirs.indd i ffirs.indd i 10/8/2012 8:54:40 AM 10/8/2012 8:54:40 AM
PART V ADVANCED TOPICS
CHAPTER 16 Inheritance and Polymorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
CHAPTER 17 Printing and Threading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501
CHAPTER 18 Web Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
APPENDIX Answers to Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577
ffirs.indd ii ffirs.indd ii 10/8/2012 8:54:40 AM 10/8/2012 8:54:40 AM
BEGINNING
Object-Oriented Programming
with C#
ffirs.indd iii ffirs.indd iii 10/8/2012 8:54:40 AM 10/8/2012 8:54:40 AM
ffirs.indd iv ffirs.indd iv 10/8/2012 8:54:40 AM 10/8/2012 8:54:40 AM
BEGINNING
Object-Oriented Programming
with C#
Jack Purdum
ffirs.indd v ffirs.indd v 10/8/2012 8:54:40 AM 10/8/2012 8:54:40 AM
Beginning Object-Oriented Programming with C#
Published by
John Wiley & Sons, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2013 by John Wiley & Sons, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-1-118-33692-2
ISBN: 978-1-118-38794-8 (ebk)
ISBN: 978-1-118-41647-1 (ebk)
ISBN: 978-1-118-54075-6 (ebk)
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108
of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization
through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers,
MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the
Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-
6008, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with
respect to the accuracy or completeness of the contents of this work and specifi cally disclaim all warranties, including
without limitation warranties of fi tness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold
with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services.
If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to
in this work as a citation and/or a potential source of further information does not mean that the author or the publisher
endorses the information the organization or Web site may provide or recommendations it may make. Further, readers
should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was
written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the
United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with
standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media
such as a CD or DVD that is not included in the version you purchased, you may download this material at
http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com.
Library of Congress Control Number: 2012948651
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affi liates, in the United States and other countries,
and may not be used without written permission. All other trademarks are the property of their respective owners. John
Wiley & Sons, Inc., is not associated with any product or vendor mentioned in this book.
ffirs.indd vi ffirs.indd vi 10/8/2012 8:54:41 AM 10/8/2012 8:54:41 AM
To Jane
ffirs.indd vii ffirs.indd vii 10/8/2012 8:54:42 AM 10/8/2012 8:54:42 AM
ffirs.indd viii ffirs.indd viii 10/8/2012 8:54:42 AM 10/8/2012 8:54:42 AM
ABOUT THE AUTHOR
DR. JACK PURDUM started his programming career on an IBM 360 mainframe
as a graduate student in the 1960s. In the mid-1970s, he became interested
in software development for microcomputers, and he founded his own software development company (Ecosoft, Inc.) in 1977. The company’s main
product was a statistics package (Microstat) that he wanted to rewrite in a
new language called C. Lacking a suitable C compiler, Dr. Purdum’s company
developed its own MS-DOS-based C compiler and other programming tools.
He has been involved with language instruction ever since. Dr. Purdum has
authored 17 texts and numerous programming articles and has received several teaching awards. He
retired from Purdue University’s College of Technology and is currently involved with on-site training and embedded systems programming.
ffirs.indd ix ffirs.indd ix 10/8/2012 8:54:42 AM 10/8/2012 8:54:42 AM
ffirs.indd x ffirs.indd x 10/8/2012 8:54:42 AM 10/8/2012 8:54:42 AM
CREDITS
Executive Editor
Robert Elliott
Project Editor
Tom Dinse
Technical Editor
Rod Stephens
Production Editor
Rebecca Anderson
Copy Editor
Apostrophe Editing Services
Editorial Manager
Mary Beth Wakefi eld
Freelancer Editorial Manager
Rosemarie Graham
Associate Director of Marketing
David Mayhew
Marketing Manager
Ashley Zurcher
Business Manager
Amy Knies
Production Manager
Tim Tate
Vice President and Executive Group
Publisher
Richard Swadley
Vice President and Executive
Publisher
Neil Edde
Associate Publisher
Jim Minatel
Project Coordinator, Cover
Katie Crocker
Proofreader
Sarah Kaikini, Word One
Indexer
Johnna VanHoose
Cover Designer
LeAndra Young
Cover Image
© Vladislav Lebedinski / iStockPhoto
ffirs.indd xi ffirs.indd xi 10/8/2012 8:54:42 AM 10/8/2012 8:54:42 AM
ffirs.indd xii ffirs.indd xii 10/8/2012 8:54:42 AM 10/8/2012 8:54:42 AM
ACKNOWLEDGMENTS
NO BOOK IS WRITTEN without massive effort by others. Tom Dinse and the editorial staff at Wrox
have all made this a better book.
A large group of people also contributed to this book in a variety of different ways, providing everything from encouragement to ideas for examples. First, thanks to my students who served as guinea
pigs for virtually everything used in this text. Others who contributed include Jerry and Barb Forro,
Bill Gromer, Joe Kack, Katie Mohr, John Purdum, and John Strack. A special vote of appreciation
to Jane Holcer for her unwavering support and encouragement throughout the process of writing
this book.
ffirs.indd xiii ffirs.indd xiii 10/8/2012 8:54:42 AM 10/8/2012 8:54:42 AM