100% found this document useful (2 votes)
5 views

Essential C# 12.0, 8th Edition Mark Michaelis instant download

Essential C# 12.0, 8th Edition by Mark Michaelis is a comprehensive guide to the C# programming language, covering fundamental concepts, data types, control flow, and advanced topics such as multithreading and asynchronous programming. The book emphasizes inclusivity and diversity in educational content, aiming to provide equitable learning opportunities. It includes detailed explanations, practical examples, and a structured approach to mastering C# for developers of all levels.

Uploaded by

mickssraaumtd
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
5 views

Essential C# 12.0, 8th Edition Mark Michaelis instant download

Essential C# 12.0, 8th Edition by Mark Michaelis is a comprehensive guide to the C# programming language, covering fundamental concepts, data types, control flow, and advanced topics such as multithreading and asynchronous programming. The book emphasizes inclusivity and diversity in educational content, aiming to provide equitable learning opportunities. It includes detailed explanations, practical examples, and a structured approach to mastering C# for developers of all levels.

Uploaded by

mickssraaumtd
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

Essential C# 12.

0, 8th Edition Mark Michaelis


download

https://textbookfull.com/product/essential-c-12-0-8th-edition-
mark-michaelis/

Download more ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Essential C 8 0 7th Edition Mark Michaelis Kevin Bost


Editor Eric Lippert Editor

https://textbookfull.com/product/essential-c-8-0-7th-edition-
mark-michaelis-kevin-bost-editor-eric-lippert-editor/

Biota Grow 2C gather 2C cook Loucas

https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-
loucas/

Pediatric Reference Intervals 8th Edition Edward C C


Wong Carlo Brugnara Joely Straseski Mark Kellogg
Khosrow Adeli

https://textbookfull.com/product/pediatric-reference-
intervals-8th-edition-edward-c-c-wong-carlo-brugnara-joely-
straseski-mark-kellogg-khosrow-adeli/

MacBook For Dummies 8th Edition Chambers Mark L

https://textbookfull.com/product/macbook-for-dummies-8th-edition-
chambers-mark-l/
MacBook For Dummies 8th Edition Chambers Mark L

https://textbookfull.com/product/macbook-for-dummies-8th-edition-
chambers-mark-l-2/

MacBook For Dummies 8th Edition Chambers Mark L

https://textbookfull.com/product/macbook-for-dummies-8th-edition-
chambers-mark-l-3/

NOLO s Essential Guide to Divorce 8th Edition Emily


Doskow

https://textbookfull.com/product/nolo-s-essential-guide-to-
divorce-8th-edition-emily-doskow/

Rob & Smith's Operative Pediatric Surgery 8th Edition


Mark Davenport

https://textbookfull.com/product/rob-smiths-operative-pediatric-
surgery-8th-edition-mark-davenport/

Structural Analysis 8th Edition Solutions Manual


Russell C. Hibbeler

https://textbookfull.com/product/structural-analysis-8th-edition-
solutions-manual-russell-c-hibbeler/
Essential
C# 12.0

Mark Michaelis
with Kevin Bost,
Technical Editor

Addison-Wesley
Hoboken, New Jersey
Cover image: Iam_Anuphone/Shutterstock

Microsoft, Windows, Visual Basic, Visual C#, and Visual C++ are either registered trademarks
or trademarks of Microsoft Corporation in the U.S.A. and/or other countries/regions.

Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in this book, and the publisher was
aware of a trademark claim, the designations have been printed with initial capital letters or in all
capitals.

The author and publisher have taken care in the preparation of this book, but make no expressed
or implied warranty of any kind and assume no responsibility for errors or omissions. No
liability is assumed for incidental or consequential damages in connection with or arising out of
the use of the information or programs contained herein.
For information about buying this title in bulk quantities, or for special sales opportunities
(which may include electronic versions; custom cover designs; and content particular to your
business, training goals, marketing focus, or branding interests), please contact our corporate
sales department at corpsales@pearsoned.com or (800) 382-3419.

For government sales inquiries, please contact governmentsales@pearsoned.com.

For questions about sales outside the U.S., please contact intlcs@pearson.com.
Visit us on the Web: informit.com/aw

Library of Congress Control Number: 2023941980


Copyright © 2024 Pearson Education, Inc.

All rights reserved. This publication is protected by copyright, and permission must be obtained
from the publisher prior to any prohibited reproduction, storage in a retrieval system, or
transmission in any form or by any means, electronic, mechanical, photocopying, recording, or
likewise. For information regarding permissions, request forms and the appropriate contacts
within the Pearson Education Global Rights & Permissions Department, please visit
www.pearson.com/permissions/.

ISBN-13: 978-0-13-821951-2
ISBN-10: 0-13-821951-6
$PrintCode
To my family: Elisabeth, Benjamin, Hanna, and Abigail. You
have sacrificed a husband and daddy for countless hours of
writing, frequently at times when he was needed most.

Thanks!

Also, to my friends and colleagues at IntelliTect. Thanks for


filling in for me when I was writing rather than doing my job
and for helping with the myriad of details to improve the
content and keep a code base like this running smoothly.
Thanks especially for making the EssentialCSharp.com
website a reality.
Pearson’s Commitment to Diversity, Equity, and Inclusion
Pearson is dedicated to creating bias-free content that reflects the diversity of all
learners. We embrace the many dimensions of diversity, including but not limited to
race, ethnicity, gender, socioeconomic status, ability, age, sexual orientation, and
religious or political beliefs.
Education is a powerful force for equity and change in our world. It has the
potential to deliver opportunities that improve lives and enable economic mobility.
As we work with authors to create content for every product and service, we
acknowledge our responsibility to demonstrate inclusivity and incorporate diverse
scholarship so that everyone can achieve their potential through learning. As the
world’s leading learning company, we have a duty to help drive change and live up to
our purpose to help more people create a better life for themselves and to create a
better world.
Our ambition is to purposefully contribute to a world where:

• Everyone has an equitable and lifelong opportunity to succeed through


learning.
• Our educational products and services are inclusive and represent the rich
diversity of learners.
• Our educational content accurately reflects the histories and experiences of the
learners we serve.
• Our educational content prompts deeper discussions with learners and
motivates them to expand their own learning (and worldview).

While we work hard to present unbiased content, we want to hear from you about
any concerns or needs with this Pearson product so that we can investigate and
address them.

• Please contact us with concerns about any potential bias at https://


www.pearson.com/report-bias.html.
Contents at a Glance

Contents vii
Foreword xv
Preface xvii
Acknowledgments xxxi
About the Author xxxiii
1 Introducing C# 1
2 Data Types 49
3 More with Data Types 93
4 Operators and Control Flow 137
5 Parameters and Methods 217
6 Classes 293
7 Inheritance 385
8 Interfaces 443
9 Introducing Structs and Records 487
10 Well-Formed Types 547
11 Exception Handling 601
12 Generics 623
13 Delegates and Lambda Expressions 683
14 Events 727
15 Collection Interfaces with Standard Query Operators 755
16 LINQ with Query Expressions 809
17 Building Custom Collections 833

v
vi Contents at a Glance

18 Reflection, Attributes, and Dynamic Programming 881


19 Introducing Multithreading 933
20 Programming the Task-Based Asynchronous Pattern 975
21 Iterating in Parallel 1021
22 Thread Synchronization 1041
23 Platform Interoperability and Unsafe Code 1077
24 The Common Language Infrastructure 1107
Index 1131
Index of 8.0 Topics 1187
Index of 9.0 Topics 1190
Index of 10.0 Topics 1191
Index of 11.0 Topics 1192
Index of 12.0 Topics 1193
Contents

Foreword xv
Preface xvii
Acknowledgments xxxi
About the Author xxxiii
1 Introducing C# 1
Hello, World 2
C# Syntax Fundamentals 12
Working with Variables 24
Console Input and Output 28
Managed Execution and the Common Language Infrastructure 38
Multiple .NET Frameworks 44
Summary 48
2 Data Types 49
Type Name Forms 50
Fundamental Numeric Types 52
More Fundamental Types 63
Conversions between Data Types 84
Summary 92
3 More with Data Types 93
Categories of Types 93
Declaring Types That Allow null 96
Implicitly Typed Local Variables 102
Tuples 103
Arrays 112

vii
viii Contents

Summary 134
4 Operators and Control Flow 137
Operators 137
Introducing Flow Control 156
Code Blocks ({}) 161
Code Blocks, Scopes, and Declaration Spaces 164
Boolean Expressions 166
Programming with null 173
Bitwise Operators (<<, >>, |, &, ^, ~) 181
Control Flow Statements, Continued 187
Jump Statements 200
C# Preprocessor Directives 206
Summary 215
5 Parameters and Methods 217
Calling a Method 218
Declaring a Method 225
Local Functions 232
Using Directives 233
Returns and Parameters on Main Method 242
Top-Level Statements 246
Advanced Method Parameters 247
Recursion 261
Method Overloading 264
Optional Parameters 267
Basic Error Handling with Exceptions 272
Summary 291
6 Classes 293
Declaring and Instantiating a Class 298
Instance Fields 302
Instance Methods 305
Using the this Keyword 306
Access Modifiers 314
Properties 316
Contents ix

Constructors 333
Non-Nullable Reference Type Properties with Constructors 346
Nullable Attributes 354
Deconstructors 357
Static Members 359
Extension Methods 370
Encapsulating the Data 372
Nested Classes 376
Partial Classes 379
Summary 384
7 Inheritance 385
Derivation 386
Overriding the Base Class 397
Abstract Classes 410
All Classes Derive from System.Object 417
Type Checking 419
Pattern Matching 423
Avoid Pattern Matching When Polymorphism Is Possible 438
Summary 440
8 Interfaces 443
Introducing Interfaces 444
Polymorphism through Interfaces 446
Interface Implementation 451
Converting between the Implementing Class and Its Interfaces 457
Interface Inheritance 458
Multiple Interface Inheritance 461
Extension Methods on Interfaces 461
Versioning 464
Extension Methods versus Default Interface Members 480
Interfaces Compared with Abstract Classes 482
Interfaces Compared with Attributes 484
Summary 484
9 Introducing Structs and Records 487
x Contents

Reference Equality versus Value Equality 493


Structs 494
Record Classes 500
Record Class Inheritance 503
Records 504
Overriding object Members 513
Customizing Record Behavior 521
Boxing 523
Enums 532
Summary 544
10 Well-Formed Types 547
Operator Overloading 548
Referencing Other Assemblies 557
Encapsulation of Types 564
Defining Namespaces 567
XML Comments 571
Garbage Collection and Weak References 576
Resource Cleanup 580
Lazy Initialization 596
Summary 598
11 Exception Handling 601
Multiple Exception Types 601
Catching Exceptions 604
Rethrowing an Existing Exception 607
General Catch Block 609
Guidelines for Exception Handling 610
Defining Custom Exceptions 614
Rethrowing a Wrapped Exception 618
Summary 622
12 Generics 623
C# without Generics 624
Introducing Generic Types 630
Constraints 646
Contents xi

Generic Methods 663


Covariance and Contravariance 669
Generic Internals 676
Summary 681
13 Delegates and Lambda Expressions 683
Introducing Delegates 684
Declaring Delegate Types 688
Lambda Expressions 698
Statement Lambdas 699
Expression Lambdas 702
Anonymous Methods 705
Delegates Do Not Have Structural Equality 707
Outer Variables 710
Static Anonymous Functions 712
Expression Trees 716
Summary 724
14 Events 727
Coding the Publish–Subscribe Pattern with Multicast Delegates 728
Understanding Events 743
Summary 753
15 Collection Interfaces with Standard Query Operators 755
Collection Initializers 756
What Makes a Class a Collection: IEnumerable 759
Standard Query Operators 766
Anonymous Types with LINQ 796
Summary 806
16 LINQ with Query Expressions 809
Introducing Query Expressions 810
Query Expressions Are Just Method Invocations 829
Summary 831
17 Building Custom Collections 833
More Collection Interfaces 834
Primary Collection Classes 837
xii Contents

Providing an Indexer 859


Returning null or an Empty Collection 862
Iterators 863
Summary 879
18 Reflection, Attributes, and Dynamic Programming 881
Reflection 881
nameof Operator 894
Attributes 895
Programming with Dynamic Objects 920
Summary 931
19 Introducing Multithreading 933
Multithreading Basics 935
Asynchronous Tasks 943
Canceling a Task 965
Working with System.Threading 972
Summary 973
20 Programming the Task-Based Asynchronous Pattern 975
Synchronously Invoking a High-Latency Operation 975
Asynchronously Invoking a High-Latency Operation Using the TPL 979
The Task-Based Asynchronous Pattern with async and await 984
Introducing Asynchronous Return of ValueTask<T> 991
Asynchronous Streams 994
IAsyncDisposable and the await using Declaration and Statement 998
Using LINQ with IAsyncEnumerable 999
Returning void from an Asynchronous Method 1001
Asynchronous Lambdas and Local Functions 1006
Task Schedulers and the Synchronization Context 1013
async/await with the Windows UI 1015
Summary 1019
21 Iterating in Parallel 1021
Executing Loop Iterations in Parallel 1021
Running LINQ Queries in Parallel 1032
Contents xiii

Summary 1039
22 Thread Synchronization 1041
Why Synchronization? 1042
Timers 1073
Summary 1076
23 Platform Interoperability and Unsafe Code 1077
Platform Invoke 1078
Pointers and Addresses 1093
Executing Unsafe Code via a Delegate 1104
Summary 1105
24 The Common Language Infrastructure 1107
Defining the Common Language Infrastructure 1107
CLI Implementations 1109
.NET Standard 1113
Base Class Library 1113
C# Compilation to Machine Code 1114
Runtime 1116
Assemblies, Manifests, and Modules 1121
Common Intermediate Language 1124
Common Type System 1125
Common Language Specification 1125
Metadata 1126
.NET Native and Ahead of Time Compilation 1127
Summary 1128
Index 1131
Index of 8.0 Topics 1187
Index of 9.0 Topics 1190
Index of 10.0 Topics 1191
Index of 11.0 Topics 1192
Index of 12.0 Topics 1193
This page intentionally left blank
Foreword
Welcome to one of the most venerable and trusted franchises you could dream of in
the world of C# books—and probably far beyond! Mark Michaelis’s Essential C#
book has been a classic for years, but it was yet to see the light of day when I first got
to know Mark.
In 2005, when LINQ (Language Integrated Query) was disclosed, I had only just
joined Microsoft, and I got to tag along to the PDC conference for the big reveal.
Despite my almost total lack of contribution to the technology, I thoroughly enjoyed
the hype. The talks were overflowing, the printed leaflets were flying off the tables
like hotcakes: It was a big day for C# and .NET, and I was having a great time.
It was pretty quiet in the hands-on labs area, though, where people could try out
the technology preview themselves with nice scripted walkthroughs. That’s where I
ran into Mark. Needless to say, he wasn’t following the script. He was doing his own
experiments, combing through the docs, talking to other folks, busily pulling together
his own picture.
As a newcomer to the C# community, I may have met a lot of people for the first
time at that conference—people with whom I have since formed great relationships.
But to be honest, I don’t remember them—it’s all a blur. The only one I remember
is Mark. Here is why: When I asked him if he was liking the new stuff, he didn’t just
join the rave. He was totally level-headed: “I don’t know yet. I haven’t made up my
mind about it.” He wanted to absorb and understand the full package, and until then
he wasn’t going to let anyone tell him what to think.
So instead of the quick sugar rush of affirmation I might have expected, I got to
have a frank and wholesome conversation, the first of many over the years, about
details, consequences, and concerns with this new technology. And so it remains:
Mark is an incredibly valuable community member for us language designers to
have, because he is super smart, insists on understanding everything to the core, and
has phenomenal insight into how things affect real developers. But perhaps most of
all, he is forthright and never afraid to speak his mind. If something passes the Mark
Test, then we know we can start feeling pretty good about it!

xv
xvi Foreword

These are the same qualities that make Mark such a great writer. He goes right to
the essence and communicates with great integrity, no sugarcoating, and a keen eye
for practical value and real-world problems. Mark has a great gift of providing clarity
and elucidation, and no one will help you get C# 12.0 like he does.
Enjoy!

—Mads Torgersen
Principal Architect, Microsoft
Preface
Throughout the history of software engineering, the methodology used to write
computer programs has undergone several paradigm shifts, each building on the
foundation of the former by increasing code organization and decreasing complexity.
This book takes you through these same paradigm shifts.
The beginning chapters take you through sequential programming structure, in
which statements are executed in the order in which they are written. The problem
with this model is that complexity increases exponentially as the requirements
increase. To reduce this complexity, code blocks are moved into methods, creating a
structured programming model. This allows you to call the same code block from
multiple locations within a program, without duplicating code. Even with this
construct, however, programs quickly become unwieldy and require further
abstraction. Object-oriented programming, introduced in Chapter 6, was the
response. In subsequent chapters, you will learn about additional methodologies,
such as interface-based programming, LINQ (and the transformation it makes to the
collection API), and eventually rudimentary forms of declarative programming (in
Chapter 18) via attributes.
This book has three main functions.

• It provides comprehensive coverage of the C# language, going beyond a


tutorial and offering a foundation upon which you can begin effective software
development projects.
• For readers already familiar with C#, this book provides insight into some of
the more complex programming paradigms and provides in-depth coverage of
the features introduced in the latest version of the language, C# 12.0 and
.NET 8.
• It serves as a timeless reference even after you gain proficiency with the
language.

xvii
xviii Preface

The key to successfully learning C# is to start coding as soon as possible. Don’t


wait until you are an “expert” in theory; start writing software immediately. As a
believer in iterative development, I hope this book enables even a novice
programmer to begin writing basic C# code by the end of Chapter 2.
Many topics are not covered in this book. You won’t find coverage of topics such
as ASP.NET, Entity Framework, Maui, smart client development, distributed
programming, and so on. Although these topics are relevant to .NET, to do them
justice requires books of their own. Fortunately, Essential C# 12.0 focuses on C# and
the types within the Base Class Library. Reading this book will prepare you to focus
on and develop expertise in any of the more advanced areas, given a strong
foundation in the C# langauge.

Target Audience for This Book


My challenge with this book was to keep advanced developers awake while not
abandoning beginners by using words such as assembly, link, chain, thread, and
fusion, as though the topic was more appropriate for blacksmiths than for
programmers. This book’s primary audience is experienced developers looking to
add another language to their quiver. However, I have carefully assembled this book
to provide significant value to developers at all levels.

• Beginners: If you are new to programming, this book serves as a resource to


help transition you from an entry-level programmer to a C# developer who is
comfortable with any C# programming task that’s thrown your way. This book
not only teaches you syntax but also trains you in good programming practices
that will serve you throughout your programming career.
• Structured programmers: Just as it’s best to learn a foreign language through
immersion, learning a computer language is most effective when you begin
using it before you know all the intricacies. In this vein, the book begins with a
tutorial that will be comfortable for those familiar with structured
programming, and by the end of Chapter 5, developers in this category should
feel at home writing basic control flow programs. However, the key to
excellence for C# developers is not memorizing syntax. To transition from
simple programs to enterprise development, the C# developer must think
natively in terms of objects and their relationships. To this end, Chapter 6’s
Preface xix

Beginner Topics introduce classes and object-oriented development. The role


of historically structured programming languages such as C, COBOL, and
FORTRAN is still significant but shrinking, so it behooves software engineers
to become familiar with object-oriented development. C# is an ideal language
for making this transition because it was designed with object-oriented
development as one of its core tenets.
• Object-based and object-oriented developers: C++, Java, Python, TypeScript,
and Visual Basic programmers fall into this category. Many of you are already
completely comfortable with semicolons and curly braces. A brief glance at the
code in Chapter 1 reveals that, at its core, C# is like other C- and C++-style
languages that you already know.
• C# professionals: For those already versed in C#, this book provides a
convenient reference for less frequently encountered syntax. Furthermore, it
provides insight into language details and subtleties that are seldom addressed.
Most important, it presents the guidelines and patterns for programming robust
and maintainable code. This book also aids in the task of teaching C# to others.
With the emergence of C# 3.0 through 12.0, some of the most prominent
enhancements are

1. String interpolation (see Chapter 2)

2. Implicitly typed variables (see Chapter 3)

3. Tuples (see Chapter 3)

4. Nullable reference types (see Chapter 3)

5. Pattern matching (see Chapter 4)

6. Extension methods (see Chapter 6)

7. Partial methods (see Chapter 6)

8. Default interface members (see Chapter 8)

9. Anonymous types (see Chapter 12)

10.Generics (see Chapter 12)


xx Preface

11.Lambda statements and expressions (see Chapter 13)

12.Expression trees (see Chapter 13)

13.Standard query operators (see Chapter 15)

14.Query expressions (see Chapter 16)

15.Dynamic programming (Chapter 18)

16.Multithreaded programming with the Task Programming Library and


async (Chapter 20)

17.Parallel query processing with PLINQ (Chapter 21)

18.Concurrent collections (Chapter 22)

These topics are covered in detail for those not already familiar with them. Also
pertinent to advanced C# development is the subject of pointers, covered in Chapter
23. Even experienced C# developers often do not understand this topic well.

Features of This Book


Essential C# 12.0 is a language book that adheres to the core C# Language
Specification. To help you understand the various C# constructs, it provides
numerous examples demonstrating each feature. Accompanying each concept are
guidelines and best practices, ensuring that code compiles, avoids likely pitfalls, and
achieves maximum maintainability.
To improve readability, code is specially formatted and chapters are outlined
using mind maps.

Website
The interactive website for the book, available at https://essentialcsharp.com,
provides the online chapters, which allows full text search. Shortly after this writing,
I expect the website to provide interactive code editing and client-side compilation of
Preface xxi

many of the code listings. This will allow you to focus on the language rather than
getting distracted by installations or dotnet setup issues.

Source Code Download


In addition to the EssentialCSharp.com website, all the source code is available on
GitHub at https://github.com/IntelliTect/EssentialCSharp so it can be downloaded
or cloned locally to your computer. This enables you to work through the code
samples as is or modify them and see the effects. This is a great way to learn the
intricacies of the language.

C# Coding Guidelines
One of the more significant enhancements included in Essential C# 12.0 is the C#
coding guidelines, as shown in the following example taken from Chapter 17:

Guidelines
DO ensure that equal objects have equal hash codes.
DO ensure that the hash code of an object never changes while
it is in a hash table.
DO ensure that the hashing algorithm quickly produces a well-
distributed hash.
DO ensure that the hashing algorithm is robust in any possible
object state.

These guidelines are the key to differentiating a programmer who knows the syntax
from an expert who can discern the most effective code to write based on the
circumstances. Such an expert not only gets the code to compile but does so while
following best practices that minimize bugs and enable maintenance well into the
future. The coding guidelines highlight some of the key principles that readers will
want to be sure to incorporate into their development. Visit https://intellitect.com/
Guidelines for a current list of all the guidelines.
xxii Preface

Code Samples
The code snippets in most of this text can run on most implementations of the
Common Language Infrastructure (CLI), but the focus is on the .NET
implementation. Platform- or vendor-specific libraries are seldom used except when
communicating important concepts relevant only to those platforms (e.g.,
appropriately handling the single-threaded user interface of Windows). Any code that
specifically relates to C# 8.0, 9.0, 10.0, 11.0, or 12.0 is called out in the C# version
indexes at the end of the book.
Here is a sample code listing.

Listing 1.21: Commenting Your Code

public class CommentSamples


{
public static void Main()
{
string firstName; // Variable for storing the first name
string lastName; // Variable for storing the last name

Console.WriteLine("Hey you!");

Console.Write /* No new line */ ("Enter your first name: ");


firstName = Console.ReadLine();

Console.Write /* No new line */ ("Enter your last name: ");


lastName = Console.ReadLine();

/* Display a greeting to the console


using composite formatting. */

Console.WriteLine("Your full name is {1}, {0}.",


firstName, lastName);
// This is the end
// of the program listing
}
}

The formatting is as follows:


• Comments are shown in italics.
/* Display a greeting to the console */
Preface xxiii

Console.Write /* No new line */ ("Enter your first name: ");

• Keywords are shown in bold.

static void Main() { }

• Highlighted code calls out specific code snippets that may have changed from
an earlier listing, or demonstrates the concept described in the text.

Listing 2.23: Error; string Is Immutable

Console.Write("Enter text: ");


string text = Console.ReadLine();

// UNEXPECTED: Does not convert text to uppercase


text.ToUpper();

Console.WriteLine(text);

• Incomplete listings contain an ellipsis to denote irrelevant code that has been
omitted.

// ...

Output 1.7

Hey you!
Enter your first name: Inigo
Enter your last name: Montoya

Your full name is Inigo Montoya.

• Console output is the output from a particular listing that appears following the
listing. User input for the program appears in boldface.

Although it might have been convenient to provide full code samples that you
could copy into your own programs, doing so would detract from your learning a
particular topic. Therefore, you need to modify the code samples before you can
incorporate them into your programs. The core omission is error checking, such as
xxiv Preface

exception handling. Also, code samples do not explicitly include using System
statements. You need to assume the statement throughout all samples.

Mind Maps
Each chapter’s introduction includes a mind map, which serves as an outline that
provides an at-a-glance reference to each chapter’s content. Here is an example
(taken from Chapter 6).

The theme of each chapter appears in the mind map’s center. High-level topics
spread out from the core. Mind maps allow you to absorb the flow from high-level to
more detailed concepts easily, with less chance of encountering very specific
knowledge that you might not be looking for.

Helpful Notes
Depending on your level of experience, special features will help you navigate
through the text.
Preface xxv

• Beginner Topics provide definitions or explanations targeted specifically


toward entry-level programmers.
• Advanced Topics enable experienced developers to focus on the material that
is most relevant to them.
• Callout notes highlight key principles in boxes so that readers easily recognize
their significance.
• Language Contrast sidebars identify key differences between C# and its
predecessors to aid those familiar with other languages.

How This Book Is Organized


At a high level, software engineering is about managing complexity, and it is toward
this end that I have organized Essential C# 12.0. Chapters 1–5 introduce structured
programming, which enable you to start writing simple functioning code
immediately. Chapters 6–10 present the object-oriented constructs of C#. Novice
readers should focus on fully understanding this section before they proceed to the
more advanced topics found in the remainder of this book. Chapters 12–14 introduce
additional complexity-reducing constructs, handling common patterns needed by
virtually all modern programs. This leads to dynamic programming with reflection
and attributes, which is used extensively for threading and interoperability in the
chapters that follow.
The book ends with Chapter 24 on the Common Language Infrastructure, which
describes C# within the context of the development platform in which it operates.
This chapter appears at the end because it is not C# specific and it departs from the
syntax and programming style in the rest of the book. However, this chapter is
suitable for reading at any time, perhaps most appropriately immediately following
Chapter 1.
Here is a description of each chapter (in this list, chapter numbers shown in bold
indicate the presence of C# 10.0–12.0 material).

• Chapter 1, Introducing C#: After presenting the C# “Hello World” program,


this chapter proceeds to dissect it. This should familiarize readers with the look
and feel of a C# program and provide details on how to compile and debug
xxvi Preface

their own programs. It also touches on the context of a C# program’s execution


and its intermediate language.
• Chapter 2, Data Types: Functioning programs manipulate data, and this
chapter introduces the primitive data types of C#.
• Chapter 3, More with Data Types: This chapter includes coverage of two type
categories: value types and reference types. From there, it delves into
implicitly typed local variables, tuples, the nullable modifier, and the C#
8.0–introduced feature, nullable reference types. It concludes with an in-depth
look at a primitive array structure.
• Chapter 4, Operators and Control Flow: To take advantage of the iterative
capabilities in a computer, you need to know how to include loops and
conditional logic within your program. This chapter also covers the C#
operators, data conversion, and preprocessor directives.
• Chapter 5, Methods and Parameters: This chapter investigates the details of
methods and their parameters. It includes passing by value, passing by
reference, and returning data via an out parameter. In C# 4.0, default parameter
support was added, and this chapter explains how to use default parameters.
• Chapter 6, Classes: Given the basic building blocks of a class, this chapter
combines these constructs to form fully functional types. Classes form the core
of object-oriented technology by defining the template for an object.
• Chapter 7, Inheritance: Although inheritance is a programming fundamental
to many developers, C# provides some unique constructs, such as the new
modifier. This chapter discusses the details of the inheritance syntax, including
overriding.
• Chapter 8, Interfaces: This chapter demonstrates how interfaces are used to
define the versionable interaction contract between classes. C# includes both
explicit and implicit interface member implementation, enabling an additional
encapsulation level not supported by most other languages. With the
introduction of default interface members, there is a section on interface
versioning in C# 8.0.
• Chapter 9, Introducing Structs and Records: C# 9.0 introduced the concepts
of records for structs and expanded it to reference types in C# 10. Although not
as prevalent as defining reference types, it is sometimes necessary to define
value types that behave in a fashion similar to the primitive types built into C#.
In defining how to create custom structures, this chapter also describes the
idiosyncrasies they may introduce.
Preface xxvii

• Chapter 10, Well-Formed Types: This chapter discusses more advanced type
definition. It explains how to implement operators, such as + and casts, and
describes how to encapsulate multiple classes into a single library. In addition,
the chapter demonstrates defining namespaces and XML comments and
discusses how to design classes for garbage collection.
• Chapter 11, Exception Handling: This chapter expands on the
exception-handling introduction from Chapter 5 and describes how exceptions
follow a hierarchy that enables creating custom exceptions. It also includes
some best practices on exception handling.
• Chapter 12, Generics: Generics are perhaps the core feature missing from C#
1.0. This chapter fully covers this 2.0 feature. In addition, C# 4.0 added
support for covariance and contravariance—something covered in the context
of generics in this chapter.
• Chapter 13, Delegates and Lambda Expressions: Delegates begin clearly
distinguishing C# from its predecessors by defining patterns for handling
events within code. This virtually eliminates the need for writing routines that
poll. Lambda expressions are the key concept that make C# 3.0’s LINQ
possible. This chapter explains how lambda expressions build on the delegate
construct by providing a more elegant and succinct syntax. This chapter forms
the foundation for the collection API discussed next.
• Chapter 14, Events: Encapsulated delegates, known as events, are a core
construct of the Common Language Runtime. Anonymous methods, another
C# 2.0 feature, are also presented here.
• Chapter 15, Collection Interfaces with Standard Query Operators: The simple
and yet elegantly powerful changes introduced in C# 3.0 begin to shine in this
chapter as we take a look at the extension methods of the Enumerable class.
This class makes available a collection API known as the standard query
operators, which is discussed in detail here.
• Chapter 16, LINQ with Query Expressions: Using standard query operators
alone results in some long statements that are hard to decipher. However,
query expressions provide an alternative syntax that matches closely with
SQL, as described in this chapter.
• Chapter 17, Building Custom Collections: In building custom APIs that work
against business objects, it is sometimes necessary to create custom
collections. This chapter details how to do this and in the process introduces
contextual keywords that make custom collection building easier.
xxviii Preface

• Chapter 18, Reflection, Attributes, and Dynamic Programming:


Object-oriented programming formed the basis for a paradigm shift in program
structure in the late 1980s. In a similar way, attributes facilitate declarative
programming and embedded metadata, ushering in a new paradigm. This
chapter looks at attributes and discusses how to retrieve them via reflection. It
also covers file input and output via the serialization framework within the
Base Class Library. In C# 4.0, a new keyword, dynamic, was added to the
language. This removed all type checking until runtime, a significant
expansion of what can be done with C#.
• Chapter 19, Introducing Multithreading: Most modern programs require the
use of threads to execute long-running tasks while ensuring active response to
simultaneous events. As programs become more sophisticated, they must take
additional precautions to protect data in these advanced environments.
Programming multithreaded applications is complex. This chapter introduces
how to work with tasks, including canceling them, and how to handle
exceptions executing in the task context.
• Chapter 20, Programming the Task-Based Asynchronous Pattern: This chapter
delves into the task-based asynchronous pattern with its accompanying async/
await syntax. It provides a significantly simplified approach to multithreaded
programming. In addition, the C# 8.0 concept of asynchronous streams is
included.
• Chapter 21, Iterating in Parallel: One easy way to introduce performance
improvements is by iterating through data in parallel using a Parallel object or
with the Parallel LINQ library.
• Chapter 22, Thread Synchronization: Building on the preceding chapter, this
chapter demonstrates some of the built-in threading pattern support that can
simplify the explicit control of multithreaded code.
• Chapter 23, Platform Interoperability and Unsafe Code: Given that C# is a
relatively young language, far more code is written in other languages than in
C#. To take advantage of this preexisting code, C# supports interoperability—
the calling of unmanaged code—through P/Invoke. In addition, C# provides
for the use of pointers and direct memory manipulation. Although code with
pointers requires special privileges to run, it provides the power to interoperate
fully with traditional C-based application programming interfaces.
• Chapter 24, The Common Language Infrastructure: Fundamentally, C# is the
syntax that was designed as the most effective programming language on top
of the underlying Common Language Infrastructure. This chapter delves into
how C# programs relate to the underlying runtime and its specifications.
Random documents with unrelated
content Scribd suggests to you:
Transcriber's Note
Page headers in the original text have been moved above or next to the paragraph to
which they relate.
The index was printed with many punctuation errors in the index. Some have been
corrected without further note, but remaining inconsistencies include the use of B. and B
as abbreviations, reference to Volume numbers as I or Vol. I, and use of a semi-colon or
a comma after et seq.. Many page numbers in the index were printed out of numerical
order.
The following apparent errors have also been changed:

p. 17 "fouud" changed to "found"


p. 20 (note) "aristically" changed to "artistically"
p. 20 "A[rch-]D[uke]." changed to "A[rch-]D[uke].”"
p. 42 "the the greatest" changed to "the greatest"
p. 49 (note) "“Zweit. Beeth.”, pp. 467" changed to "“Zweit. Beeth.,” pp. 467"
p. 60 "expecially" changed to "especially"
p. 76 "all right." changed to "all right.”"
p. 83 "to to Hensler" changed to "to Hensler"
p. 89 "cermony" changed to "ceremony"
p. 93 "disinteredness" changed to "disinterestedness"
p. 94 "contempories" changed to "contemporaries"
p. 99 "indentical" changed to "identical"
p. 104 "almost O" changed to "almost 0"
p. 128 "also fuming" changed to "was also fuming"
p. 144 "1915" changed to "1815"
p. 146 "Pianofortes Sonatas" changed to "Pianoforte Sonatas"
p. 148 "final chorus" changed to "final chorus)"
p. 150 "(nor this either" changed to "nor this either"
p. 161 "vexations" changed to "vexatious"
p. 196 "castrophe" changed to "catastrophe"
p. 215 "31ème Quatuor." changed to "“31ème Quatuor."
p. 219 "semblence" changed to "semblance"
p. 222 "Leibquartett" changed to "Liebquartett"
p. 224 "he, remarked" changed to "he remarked"
p. 224 "“Must it be?" changed to "“Must it be?”"
p. 227 "life, time" changed to "lifetime"
p. 239 "Schwarzspanierhaus" changed to "Schwarzspanierhause"
p. 252 "toward each," changed to "toward each"
p. 252 "solicituous" changed to "solicitous"
p. 259 "capable practioner" changed to "capable practitioner"
p. 272 "Schwarzpanierhaus" changed to "Schwarzspanierhaus"
p. 274 "has thought" changed to "has been thought"
p. 294 "ensured" changed to "ensued"
p. 304 "but Beetthoven" changed to "but Beethoven"
p. 305 (note) "farce is done.’" changed to "farce is done.’”"
p. 309 "Beethovens death" changed to "Beethoven’s death"
p. 310 "preserved." changed to "preserved.”"
p. 315 "‘Alfred the Great”" changed to "“Alfred the Great”"
p. 316 "42," changed to "42."
p. 316 "77 wants" changed to "77; wants"
p. 316 "to, 218," changed to "to, 218."
p. 317 "104; 190" changed to "104, 190"
p. 317 "132; 134;" changed to "132, 134;"
p. 317 "103; 191" changed to "103, 191"
p. 317 "xi; 192" changed to "xi, 192"
p. 320 "368; 362" changed to "368, 362"
p. 320 "280 286" changed to "280, 286"
p. 321 "176 Matthisson" changed to "176; Matthisson"
p. 321 "344, Magdalena" changed to "344; Magdalena"
p. 321 "Rovantini I, 64" changed to "Rovantini, I, 64"
p. 322 "et seq.; 364;" changed to "et seq., 364;"
p. 322 "37; 118" changed to "37, 118"
p. 323 "200; 219" changed to "200, 219"
p. 324 "“Fidelio”; II" changed to "“Fidelio”, II"
p. 324 "et seq.; 141." changed to "et seq., 141."
p. 324 "3; 36;" changed to "3, 36;"
p. 324 "asked by B to" changed to "asked by B. to"
p. 324 "I, 1 et seq." changed to "I, 1 et seq.;"
p. 325 "Dedication; 88;" changed to "Dedication, 88;"
p. 326 "Singer, III: 169." changed to "Singer: III, 169."
p. 326 "court, I, 29," changed to "court: I, 29,"
p. 328 "Künstler”" changed to "Künstler"
p. 328 "182, 202," changed to "182, 202."
p. 328 "II, 80:" changed to "II, 80;"
p. 329 "II, 127:" changed to "II, 127;"
p. 329 "teacher, 152," changed to "teacher, 152;"
p. 329 "284, 285," changed to "284, 285;"
p. 329 "teacher, 11," changed to "teacher, 11;"
p. 330 "Oratorio by by C. P. E. Bach" changed to "Oratorio by C. P. E. Bach"
p. 332 "La finta Giardiniera”" changed to "“La finta Giardiniera”"
p. 334 "B’s visit to 89, 90;" changed to "B’s visit to, 89, 90;"
p. 334 "Mihl, 31" changed to "Mihl, I, 31"
p. 335 "I, 282," changed to "I, 282;"
p. 336 "La buona Figluola." changed to "La buona Figluola,"
p. 336 "B. plays in." changed to "B. plays in,"
p. 337 "plays the the C minor" changed to "plays the C minor"
p. 338 "Rzwuska" changed to "Rzewuska"
p. 339 "“Seidenen Schuhe,” Die" changed to "“Seidenen Schuhe, Die”"
p. 341 "III, 77, 78; III, 161," changed to "III, 77, 78, 161,"
p. 346 "Hoffmann, sei" changed to "“Hoffmann, sei"
The following possible errors have not been changed:

p. 17 The gentleman has not eaten anything yet"


p. 122 St. Wenzelaus
p. 231 the necessity off proving
p. 231 Yours sincerly
p. 343 II, 113, 144;

The following are inconsistently used:

absentmindedness and absent-mindedness


deathbed and death-bed
Haslinger and Hasslinger
hellhound and hell-hound
Lodoïska and Lodoiska
notebook and note-book
sickbed and sick-bed
sketchbooks and sketch-books
stagecoach and stage-coach
Süssmayer and Süssmayr
Theaterzeitung and Theater-Zeitung
W.W. and W. W.
Zémire and Zemire
*** END OF THE PROJECT GUTENBERG EBOOK THE LIFE OF
LUDWIG VAN BEETHOVEN, VOLUME III ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree
to abide by all the terms of this agreement, you must cease
using and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project Gutenberg™
works in compliance with the terms of this agreement for
keeping the Project Gutenberg™ name associated with the
work. You can easily comply with the terms of this agreement
by keeping this work in the same format with its attached full
Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.

1.E. Unless you have removed all references to Project


Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:

This eBook is for the use of anyone anywhere in the United


States and most other parts of the world at no cost and
with almost no restrictions whatsoever. You may copy it,
give it away or re-use it under the terms of the Project
Gutenberg License included with this eBook or online at
www.gutenberg.org. If you are not located in the United
States, you will have to check the laws of the country
where you are located before using this eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is


derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of
the copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is


posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute


this electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the
Project Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™
works unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or


providing access to or distributing Project Gutenberg™
electronic works provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project


Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite these
efforts, Project Gutenberg™ electronic works, and the medium
on which they may be stored, may contain “Defects,” such as,
but not limited to, incomplete, inaccurate or corrupt data,
transcription errors, a copyright or other intellectual property
infringement, a defective or damaged disk or other medium, a
computer virus, or computer codes that damage or cannot be
read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except


for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU AGREE
THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT
LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT
EXCEPT THOSE PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE
THAT THE FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person
or entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you
do or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status
by the Internal Revenue Service. The Foundation’s EIN or
federal tax identification number is 64-6221541. Contributions
to the Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact
Section 4. Information about Donations to
the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or determine
the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.

Please check the Project Gutenberg web pages for current


donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.
back
back
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like