Programming C# 10: Build Cloud, Web and Desktop Applications (Final Early Release) Ian Griffiths All Chapters Instant Download
Programming C# 10: Build Cloud, Web and Desktop Applications (Final Early Release) Ian Griffiths All Chapters Instant Download
com
https://ebookmeta.com/product/programming-c-10-build-cloud-
web-and-desktop-applications-final-early-release-ian-
griffiths/
OR CLICK BUTTON
DOWNLOAD NOW
https://ebookmeta.com/product/programming-c-4-0-6th-edition-ian-
griffiths-matthew-adams-jesse-liberty/
ebookmeta.com
https://ebookmeta.com/product/the-deathless-sons-1st-edition-brendan-
noble/
ebookmeta.com
Alex Mercer 11 Careless Whisper 1st Edition Stacy Claflin
https://ebookmeta.com/product/alex-mercer-11-careless-whisper-1st-
edition-stacy-claflin/
ebookmeta.com
https://ebookmeta.com/product/curtain-of-death-book-3-of-clandestine-
operations-1st-edition-w-e-b-griffin-william-e-butterworth-iv/
ebookmeta.com
Ian Griffiths
Programming C# 10
by Ian Griffiths
Copyright © 2022 Ian Griffiths. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North,
Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales
promotional use. Online editions are also available for most titles
(http://oreilly.com). For more information, contact our
corporate/institutional sales department: 800-998-9938 or
corporate@oreilly.com.
C# has now existed for around two decades. It has grown steadily in both
power and size, but Microsoft has always kept the essential characteristics
intact. Each new capability is designed to integrate cleanly with the rest,
enhancing the language without turning it into an incoherent bag of
miscellaneous features.
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. Because there is so much ground to cover, this book expects a
certain level of technical ability from its readers.
Who This Book Is For
I have written this book for experienced developers—I’ve been
programming for years, and I 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 earlier 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.
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.
NOTE
This element signifies a general note.
WARNING
This element indicates a warning or caution.
NOTE
For more than 40 years, O’Reilly 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. O’Reilly’s 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 O’Reilly 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:
Sebastopol, CA 95472
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/library/view/programming-c-10/9781098117801/.
Email us with comments or technical questions at
bookquestions@oreilly.com.
For more information about our books, courses, conferences, and news, see
our website at http://www.oreilly.com.
Find us on LinkedIn: https://linkedin.com/company/oreilly-media
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://http.youtube.com/oreillymedia
Acknowledgments
Many thanks to the book’s official technical reviewers: Stephen Toub,
Howard van Rooijen, and Glyn Griffiths. I’d also like to give a big thank
you to those who reviewed individual chapters, or otherwise offered help or
information that improved this book: Brian Rasmussen, Eric Lippert,
Andrew Kennedy, Daniel Sinclair, Brian Randell, Mike Woodring, Mike
Taulty, Bart De Smet, Matthew Adams, Jess Panni, Jonathan George, Mike
Larah, Carmel Eve, Ed Freeman, Elisenda Gascon, Jessica Hill, Liam
Mooney, Nehemiah Campbell, and Shahryar Saljoughi. Thanks in particular
to endjin, both for allowing me to take time out from work to write this
book, and also for creating such a great place to work.
Thank you to everyone at O’Reilly whose work brought this book into
existence. In particular, thanks to Corbin Collins for his support in making
this book happen, and to Tyler Ortman for his support in getting this project
started. Thanks also to Cassandra Furtado, Deborah Baker, Ron Bilodeau,
Nick Adams, Rebecca Demarest, Karen Montgomery, and Kristen Brown,
for their help in bringing the work to completion. Thanks also to Kim Cofer
for her thorough and thoughtful copy editing, and Kim Sandoval’s diligent
proofreading. Finally, thank you to John Osborn, for taking me on as an
O’Reilly author back when I wrote my first book.
Chapter 1. Introducing C#
Why C#?
Although there are many ways you can use C#, other languages are always
an option. Why might you choose C# over those? It will depend on what
you need to do, and what you like and dislike in a programming language. I
find that C# provides considerable power, flexibility, and performance, and
works at a high enough level of abstraction that I don’t expend vast
amounts of effort on little details not directly related to the problems my
programs are trying to solve.
Much of C#’s power comes from the range of programming techniques it
supports. For example, it offers object-oriented features, generics, and
functional programming. It supports both dynamic and static typing. It
provides powerful list- and set-oriented features, thanks to Language
Integrated Query (LINQ). It has intrinsic support for asynchronous
programming. Moreover, the various development environments that
support C# all offer a wide range of productivity enhancing features.
C# provides options for balancing ease of development against
performance. The runtime has always provided a garbage collector (GC)
that frees developers from much of the work associated with recovering
memory that the program is no longer using. A GC is a common feature in
modern programming languages, and while it is a boon for most programs,
there are some specialized scenarios where its performance implications are
problematic, so C# enables more explicit memory management, giving you
the option to trade ease of development for runtime performance, but
without the loss of type safety. This makes C# suitable for certain
performance-critical applications that for years were the preserve of less
safe languages such as C and C++.
Languages do not exist in a vacuum—high-quality libraries with a broad
range of features are essential. Some elegant and academically beautiful
languages are glorious right up until you want to do something prosaic,
such as talking to a database or determining where to store user settings. No
matter how powerful a set of programming idioms a language offers, it also
needs to provide full and convenient access to the underlying platform’s
services. C# is on very strong ground here, thanks to its runtime, built-in
class libraries, and extensive third-party library support.
.NET encompasses both the runtime and the main class libraries that C#
programs use. The runtime part is called the Common Language Runtime
(usually abbreviated to CLR) because it supports not just C#, but any .NET
language. Microsoft also offers Visual Basic, F#, and .NET extensions for
C++, for example. The CLR has a Common Type System (CTS) that enables
code from multiple languages to interoperate freely, which means that .NET
libraries can normally be used from any .NET language—F# can consume
libraries written in C#, C# can use Visual Basic libraries, and so on.
There is an extensive set of class libraries built into .NET. These have gone
by a few names over the years, including Base Class Library (BCL),
Framework Class Library, and framework libraries, but Microsoft now
seems to have settled on runtime libraries as the name for this part of .NET.
These libraries provide wrappers for many features of the underlying
operating system (OS), but they also provide a considerable amount of
functionality of their own, such as collection classes and JSON processing.
The .NET runtime class libraries are not the whole story—many other
systems provide their own .NET libraries. For example, there are libraries
that enable C# programs to use popular cloud services. As you’d expect,
Microsoft provides comprehensive .NET libraries for working with services
in its Azure cloud platform. Likewise, Amazon provides a fully featured
development kit for using Amazon Web Services (AWS) from C# and other
.NET languages. And libraries do not have to be associated with particular
services. There’s a large ecosystem of .NET libraries, some commercial,
and some free, including mathematical utilities, parsing libraries, and user
interface (UI) components, to name just a few. Even if you get unlucky and
need to use an OS feature that doesn’t have any .NET library wrappers, C#
offers various mechanisms for working with other kinds of APIs, such as
the C-style APIs available in Win32, macOS, and Linux, or APIs based on
the Component Object Model (COM) in Windows.
In addition to libraries there are also numerous applications frameworks.
.NET has built-in frameworks for creating web apps and web APIs, desktop
applications, and mobile applications. There are also open source
frameworks for various styles of distributed systems development such as
high-volume event processing with Reaqtor, or high-availability globally
distributed systems with project Orleans.
Finally, with .NET having been around for over two decades, many
organizations have invested extensively in technology built on this
platform. So C# is often the natural choice for reaping the rewards of these
investments.
In summary, with C# we get a strong set of abstractions built into the
language, a powerful runtime, and easy access to an enormous amount of
library and platform functionality.