A Programmer's Introduction to C# 2.0, Third Edition is a critical update to the highly successful second edition. It is written by a member of the original C# language-design team and a C# program manager, so you can be certain this book contains the expertise you're looking for.
This third edition covers the elements of C# 2005 that you’ll soon embrace. This comprehensive tutorial explains features like generics, iterators, anonymous types, and partial classes. It is sure to be a key resource for all you C# programmers!
Le informazioni nella sezione "Riassunto" possono far riferimento a edizioni diverse di questo titolo.
Eric Gunnerson is a software developer working at Microsoft. He is a past C# Test Lead, C# Program Manager, and member of the C# Language Design Team. He s been a developer for longer than he cares to admit, and has worked on everything from microcontrollers to minicomputers. In his spare time, he enjoys writing about himself in the third person.
A Programmer’s Introduction
to C# 2.0
Third Edition
ERIC GUNNERSON AND NICK WIENHOLT
A Programmer’s Introduction to C# 2.0, Third Edition
Copyright © 2005 by Eric Gunnerson and Nick Wienholt
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.
ISBN (pbk): 1-59059-501-7
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence
of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark
owner, with no intention of infringement of the trademark.
Lead Editor: Jon Hassell
Technical Reviewer: Gavin Smyth
Editorial Board: Steve Anglin, Dan Appleman, Ewan Buckingham, Gary Cornell, Tony Davis, Jason Gilmore,
Jonathan Hassell, Chris Mills, Dominic Shakeshaft, Jim Sumser
Assistant Publisher: Grace Wong
Project Manager: Kylie Johnston
Copy Edit Manager: Nicole LeClerc
Copy Editor: Kim Wimpsett
Production Manager: Kari Brooks-Copony
Compositors: Susan Glinert and Wordstop Technologies (P) Limited
Proofreader: Elizabeth Berry
Indexer: Broccoli Information Management
Artist: April Milne
Cover Designer: Kurt Krames
Interior Designer: Van Winkle Design Group
Manufacturing Manager: Tom Debolski
Distributed to the book trade in the United States by Springer-Verlag New York, Inc., 233 Spring Street,
6th Floor, New York, NY 10013, and outside the United States by Springer-Verlag GmbH & Co. KG,
Tiergartenstr. 17, 69112 Heidelberg, Germany.
In the United States: phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders@springeronline.com,
or visit http://www.springeronline.com. Outside the United States: fax +49 6221 345229,
e-mail orders@springeronline.com, or visit http://www.springeronline.com.
For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA
94710. Phone 510-549-5930, fax 510-549-5939, e-mail info@apress.com, or visit http://www.apress.com.
The information in this book is distributed on an “as is” basis, without warranty. Although every precaution
has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to
any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly
by the information contained in this work.
The source code for this book is available to readers at http://www.apress.com in the Downloads section.
v
Contents at a Glance
Foreword to the Third Edition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
Foreword to the First Two Editions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii
About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxi
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxiii
CHAPTER 1 Object-Oriented Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
CHAPTER 2 The .NET Runtime Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
CHAPTER 3 C# Quick Start and C# Development . . . . . . . . . . . . . . . . . . . . . . . . . . 11
CHAPTER 4 Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
CHAPTER 5 Classes 101 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
CHAPTER 6 Base Classes and Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
CHAPTER 7 Member Accessibility and Overloading . . . . . . . . . . . . . . . . . . . . . . . . 53
CHAPTER 8 Other Class Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
CHAPTER 9 Structs (Value Types) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
CHAPTER 10 Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
CHAPTER 11 Versioning and Aliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
CHAPTER 12 Statements and Flow of Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
CHAPTER 13 Variable Scoping and Definite Assignment . . . . . . . . . . . . . . . . . . . 113
CHAPTER 14 Operators and Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
CHAPTER 15 Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
CHAPTER 16 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
CHAPTER 17 Generics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
CHAPTER 18 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
CHAPTER 19 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
CHAPTER 20 Indexers, Enumerators, and Iterators . . . . . . . . . . . . . . . . . . . . . . . . 179
CHAPTER 21 Enumerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
vi ■CONTENTS AT A GLANCE
CHAPTER 22 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
CHAPTER 23 Delegates and Anonymous Methods . . . . . . . . . . . . . . . . . . . . . . . . . 217
CHAPTER 24 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
CHAPTER 25 User-Defined Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
CHAPTER 26 Operator Overloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
CHAPTER 27 Nullable Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
CHAPTER 28 Other Language Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
CHAPTER 29 Making Friends with the .NET Framework . . . . . . . . . . . . . . . . . . . . 283
CHAPTER 30 System.Array and the Collection Classes . . . . . . . . . . . . . . . . . . . . . 293
CHAPTER 31 Threading and Asynchronous Operations . . . . . . . . . . . . . . . . . . . . . 315
CHAPTER 32 Execution-Time Code Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
CHAPTER 33 Interop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
CHAPTER 34 .NET Framework Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
CHAPTER 35 Windows Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
CHAPTER 36 DiskDiff: More Sophistication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
CHAPTER 37 Practical DiskDiff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
CHAPTER 38 Deeper into C# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
CHAPTER 39 Defensive Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
CHAPTER 40 Tips for Real-World Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485
CHAPTER 41 The Command-Line Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493
CHAPTER 42 C# Compared to Other Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . 497
CHAPTER 43 C# Resources and the Future . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517
Le informazioni nella sezione "Su questo libro" possono far riferimento a edizioni diverse di questo titolo.
EUR 8,90 per la spedizione da Regno Unito a Italia
Destinazione, tempi e costiGRATIS per la spedizione da U.S.A. a Italia
Destinazione, tempi e costiDa: Bahamut Media, Reading, Regno Unito
Paperback. Condizione: Very Good. This book is in very good condition and will be shipped within 24 hours of ordering. The cover may have some limited signs of wear but the pages are clean, intact and the spine remains undamaged. This book has clearly been well maintained and looked after thus far. Money back guarantee if you are not satisfied. See all our books here, order more than 1 book and get discounted shipping. Codice articolo 6545-9781590595015
Quantità: 1 disponibili
Da: AwesomeBooks, Wallingford, Regno Unito
Paperback. Condizione: Very Good. A Programmer's Introduction to C# 2.0 3rd Edition (Expert's Voice) This book is in very good condition and will be shipped within 24 hours of ordering. The cover may have some limited signs of wear but the pages are clean, intact and the spine remains undamaged. This book has clearly been well maintained and looked after thus far. Money back guarantee if you are not satisfied. See all our books here, order more than 1 book and get discounted shipping. Codice articolo 7719-9781590595015
Quantità: 1 disponibili
Da: ThriftBooks-Dallas, Dallas, TX, U.S.A.
Paperback. Condizione: Good. No Jacket. Pages can have notes/highlighting. Spine may show signs of wear. ~ ThriftBooks: Read More, Spend Less 1.95. Codice articolo G1590595017I3N00
Quantità: 1 disponibili
Da: Wonder Book, Frederick, MD, U.S.A.
Condizione: Good. Good condition. 3rd edition. A copy that has been read but remains intact. May contain markings such as bookplates, stamps, limited notes and highlighting, or a few light stains. Codice articolo I11B-02677
Quantità: 1 disponibili
Da: SecondSale, Montgomery, IL, U.S.A.
Condizione: Good. Codice articolo 00050421571
Quantità: 1 disponibili
Da: Romtrade Corp., STERLING HEIGHTS, MI, U.S.A.
Condizione: New. This is a Brand-new US Edition. This Item may be shipped from US or any other country as we have multiple locations worldwide. Codice articolo ABNR-117954
Quantità: 1 disponibili
Da: Basi6 International, Irving, TX, U.S.A.
Condizione: Brand New. New. US edition. Expediting shipping for all USA and Europe orders excluding PO Box. Excellent Customer Service. Codice articolo ABEJUNE24-195422
Quantità: 1 disponibili
Da: moluna, Greven, Germania
Condizione: New. Written by a member of the original C# language design team and C# Program Manager contains the expertise that pro C# programmers wantFollows the successful first and second editions one of the earliest practical books for developers using C# 2. Codice articolo 458520108
Quantità: Più di 20 disponibili
Da: Ria Christie Collections, Uxbridge, Regno Unito
Condizione: New. In. Codice articolo ria9781590595015_new
Quantità: Più di 20 disponibili
Da: Books Puddle, New York, NY, U.S.A.
Condizione: New. pp. 572 3rd Edition. Codice articolo 26293659
Quantità: 1 disponibili