Learn C# Includes the C# 3.0 Features Sam A Abolrous Wordware Publishing, Inc Library of Congress Cataloging-in-Publication Data Abolrous, Sam A Learn C# / by Sam A Abolrous p cm Includes index ISBN-13: 978-1-59822-035-3 (pbk.) ISBN-10: 1-59822-035-7 C# (Computer program language) I Title QA76.73.C154A416 2007 005.13'3 dc22 2007024261 © 2008, Wordware Publishing, Inc All Rights Reserved 1100 Summit Avenue, Suite 102 Plano, Texas 75074 No part of this book may be reproduced in any form or by any means without permission in writing from Wordware Publishing, Inc Printed in the United States of America ISBN-13: 978-1-59822-035-3 ISBN-10: 1-59822-035-7 10 0708 All brand names and product names mentioned in this book are trademarks or service marks of their respective companies Any omission or misuse (of any kind) of service marks or trademarks should not be regarded as intent to infringe on the property of others The publisher recognizes and respects all marks used by companies, manufacturers, and developers as a means to distinguish their products This book is sold as is, without warranty of any kind, either express or implied, respecting the contents of this book and any disks or programs that may accompany it, including but not limited to implied warranties for the book’s quality, performance, merchantability, or fitness for any particular purpose Neither Wordware Publishing, Inc nor its dealers or distributors shall be liable to the purchaser or any other person or entity with respect to any liability, loss, or damage caused or alleged to have been caused directly or indirectly by this book All inquiries for volume purchases of this book should be addressed to Wordware Publishing, Inc., at the above address Telephone inquiries may be made by calling: (972) 423-0090 To Camelia, my love and my wife This page intentionally left blank Index Swap method, 141-142 using, 295-296 switch construct, 71-74 System.Array class, 85 System.Attribute class, 167 System.Collections.Generic namespace, 276 System.Exception class, 193 System.GC.Collect method, System.Nullable structure, 54 T target elements, 167 text files, appending, 206 reading, 205 writing, 206 this keyword, 115, 148, 339 throw keyword, 84, 193-194, 214 ToString method, 23 overriding, 152-153 try-catch statement, 193 using, 197-199 try-catch-finally statement, 194 using, 210-211 try-finally statement, 194 using, 208-209 two-dimensional arrays, 84, 86 type argument, 276, 292 type conversion, 46-47 explicit, 47 implicit, 46 type parameter, 276, 292 types, anonymous, 340-344 concrete, 276 converting, 46-47 generic, 276 initializing, 334-336 nullable, 53 retrieving, 43 testing, 182-185 using default, 297 U unary operators, 40 unboxing, 35-37 unions, emulating, 172-173 unsafe code, 31 user-defined exceptions, 212-213 using directive, 21 | 405 V value keyword, 106 Value property, 54 value types, 31, 33 converting to reference types, 35-37 default values of, 34 var keyword, 331 variables, captured, 229 initializing, 23, 33-34 local, 22-23 numeric, 23 outer, 229-230 range, 351 versioning, 186-189 virtual keyword, 130-131 virtual methods, overriding, 132-136 Visual Studio, Code Editor, 323-328 compiling applications in, 312 Error List window, 311 installing, 331 opening existing application in, 313 Properties window, 311 Solution Explorer, 309-310 Start Page, 305-306 starting application in, 306-307 using, 12 void type, 19 W web site applications, 320-321 creating, 321-322 executing, 322 where keyword, 297-298 while loop, 80-81 do-while loop, 83 Windows applications, creating, 316-318 running, 318-319 using multiple forms in, 319 Write method, 20 WriteLine method, 20, 23-24 using, 49-52 X XML tags, adding to code, 28-29 Y yield return statement, 269-270, 272 yield statement, 271 Looking for more? Check out Wordware’s market-leading Applications Library featuring the following titles Essential LightWave v9 1-59822-024-1 • $49.95 x • 992 pp Advanced SQL Functions in Oracle 10g 1-59822-021-7 • $36.95 x • 416 pp Camtasia Studio 4: The Definitive Guide 1-59822-037-3 • $39.95 x • 600 pp LightWave v9 Texturing 1-59822-029-2 • $44.95 x • 648 pp SQL for Microsoft Access 1-55622-092-8 • $39.95 x • 360 pp Introduction to Game Programming with C++ 1-59822-032-2 • $44.95 x • 392 pp LightWave v9 Lighting Managing Virtual Teams: Microsoft Excel Functions 1-59822-028-4 • $29.95 x • 400 pp x • 416 pp Word 2003 Document Automation with VBA, XML, XSLT and Smart Documents Access 2003 Programming by Example with VBA, XML, and ASP Excel 2003 VBA Programming with XML and ASP FileMaker Web Publishing: FileMaker Pro Business Applications Learn FileMaker Pro 1-59822-039-X • $44.95 x • 616 pp 1-55622-086-3 • $36.95 x • 464 pp A Complete Guide to Using the API for PHP 1-59822-041-1 • $49.95 x • 472 pp Getting the Most From Wikis, Blogs, & Formulas and Other Collaborative Tools 1-59822-011-X • $29.95 1-55622-223-8 • $39.95 x • 704 pp 1-59822-014-4 • $49.95 x • 648 pp www.wordware.com 1-55622-225-4 • $36.95 x • 968 pp 1-59822-046-2 • $39.95 x • 550 pp Visit us online at for more information Use the following coupon code for online specials: csharp0357 ... index ISBN- 13: 978-1-59822- 03 5 -3 (pbk.) ISBN- 10: 1-59822- 03 5 -7 C# (Computer program language) I Title QA76. 73 .C1 54A416 200 7 00 5. 13'' 3 dc22 200 702 4261 © 200 8, Wordware Publishing, Inc All Rights... Explorer, 30 9 -31 0 Start Page, 30 5 - 30 6 starting application in, 30 6 - 30 7 using, 12 void type, 19 W web site applications, 32 0 -32 1 creating, 32 1 -32 2 executing, 32 2 where keyword, 297-298 while loop, 80- 81... 1-59822 -02 8-4 • $29.95 x • 400 pp x • 416 pp Word 20 03 Document Automation with VBA, XML, XSLT and Smart Documents Access 20 03 Programming by Example with VBA, XML, and ASP Excel 20 03 VBA Programming