Programming C# 8.0
by Ian Griffiths
Copyright 2020 Ian Griffiths. All rights reserved.
Printed in the United States of America.
Published by OReilly Media, Inc. , 1005 Gravenstein Highway North, Sebastopol, CA 95472.
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (https://oreilly.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .
- Editors: Tyler Ortman and Corbin Collins
- Production Editor: Deborah Baker
- Interior Designer: David Futato
- Cover Designer: Karen Montgomery
- Illustrator: Rebecca Demarest
- November 2019: First Edition
Revision History for the Early Release
- 2019-05-24: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781492056812 for release details.
The OReilly logo is a registered trademark of OReilly Media, Inc. Programming C# 8.0, the cover image, and related trade dress are trademarks of OReilly Media, Inc.
While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
978-1-492-05674-4
[LSI]
Dedication
I dedicate this book to my excellent wife Deborah, and to my wonderful daughters, Hazel and Victoria. Thank you for enriching my life.
Preface
C# is now well into its second decade. It has grown steadily in both power and size, but Microsoft has always kept the essential characteristics intactC# still feels like the same language as was first unveiled back in 2000. Each new capability is designed to integrate cleanly with the rest, enhancing the language without turning it into an incoherent bag of miscellaneous features. This philosophy is evident in the most important new addition to C#its support for asynchronous programming. It has always been possible to use asynchronous APIs in C#, but in the past, this tended to involve convoluted code. In C# 5.0, you can write asynchronous code that looks almost exactly like normal code, so instead of adding weight to the language, this new asynchronous programming support makes things simpler.
Even though C# continues to be a fairly straightforward language at its heart, there is a great deal more to say about it now than in its first incarnation. Successive editions of this book have responded to the languages progress with ever-increasing page counts, but this latest edition does not merely try to cram in yet more details. It expects a somewhat higher level of technical ability from its readers than before.
Who This Book Is For
I have written this book for experienced developersIve been programming for years, and Ive set out to make this the book I would want to read if that experience had been in other languages, and I were learning C# today. Whereas previous editions explained some basic concepts such as classes, polymorphism, and collections, I am assuming that readers will already know what these are. The early chapters still describe how C# presents these common ideas, but the focus is on the details specific to C#, rather than the broad concepts. So if you have read previous editions of this book, you will find that this one spends less time on these basic concepts, and goes into rather more detail on everything else.
Conventions Used in This Book
The following typographical conventions are used in this book:
ItalicIndicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by values determined by context.
Tip
This element signifies a tip or suggestion.
Note
This element signifies a general note.
Warning
This element indicates a warning or caution.
Using Code Examples
Supplemental material (code examples, exercises, etc.) is available for download at https://oreil.ly/programmingcsharp.
This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless youre reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from OReilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your products documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: Programming C# 8.0 by Ian Griffiths (OReilly). Copyright 2020 by Ian Griffiths, 978-1-492-05681-2.
If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .
OReilly Online Learning
Note
For almost 40 years, OReilly has provided technology and business training, knowledge, and insight to help companies succeed.
Our unique network of experts and innovators share their knowledge and expertise through books, articles, conferences, and our online learning platform. OReillys online learning platform gives you on-demand access to live training courses, in-depth learning paths, interactive coding environments, and a vast collection of text and video from OReilly and 200+ other publishers. For more information, please visit http://oreilly.com.
How to Contact Us
Please address comments and questions concerning this book to the publisher:
- OReilly Media, Inc.
- 1005 Gravenstein Highway North
- Sebastopol, CA 95472
- 800-998-9938 (in the United States or Canada)
- 707-829-0515 (international or local)
- 707-829-0104 (fax)
We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at https://www.oreilly.com/catalog/9781492056812.
To comment or ask technical questions about this book, send email to .
For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia