Preface |
|
xvii | |
|
|
1 | (30) |
|
|
2 | (2) |
|
|
4 | (2) |
|
C# Prefers Generality to Specialization |
|
|
6 | (1) |
|
C# Standards and Implementations |
|
|
7 | (1) |
|
|
7 | (2) |
|
Release Cycles and Long Term Support |
|
|
9 | (1) |
|
Target Multiple NET Versions with NET Standard |
|
|
10 | (1) |
|
Visual Studio, Visual Studio Code, and JetBrains Rider |
|
|
11 | (3) |
|
Anatomy of a Simple Program |
|
|
14 | (5) |
|
|
19 | (3) |
|
|
22 | (5) |
|
|
27 | (2) |
|
|
29 | (1) |
|
|
30 | (1) |
|
|
31 | (76) |
|
|
32 | (6) |
|
|
38 | (1) |
|
|
39 | (2) |
|
|
41 | (1) |
|
Statements and Expressions |
|
|
42 | (1) |
|
|
42 | (2) |
|
|
44 | (6) |
|
|
50 | (2) |
|
|
52 | (1) |
|
|
52 | (2) |
|
|
54 | (1) |
|
|
54 | (1) |
|
|
55 | (1) |
|
|
56 | (1) |
|
|
56 | (1) |
|
|
57 | (1) |
|
|
57 | (11) |
|
|
68 | (1) |
|
|
69 | (7) |
|
|
76 | (4) |
|
|
80 | (1) |
|
|
81 | (1) |
|
|
82 | (6) |
|
|
88 | (1) |
|
Boolean Decisions with if Statements |
|
|
88 | (2) |
|
Multiple Choice with switch Statements |
|
|
90 | (2) |
|
|
92 | (1) |
|
|
93 | (2) |
|
Collection Iteration with foreach Loops |
|
|
95 | (1) |
|
|
96 | (5) |
|
Combining and Negating Patterns |
|
|
101 | (1) |
|
|
102 | (1) |
|
Getting More Specific with when |
|
|
103 | (1) |
|
|
103 | (3) |
|
|
106 | (1) |
|
|
107 | (100) |
|
|
107 | (3) |
|
|
110 | (2) |
|
|
112 | (2) |
|
|
114 | (5) |
|
|
119 | (5) |
|
Banishing Null with Non-Nullable References |
|
|
124 | (7) |
|
|
131 | (5) |
|
When to Write a Value Type |
|
|
136 | (4) |
|
Guaranteeing Immutability |
|
|
140 | (1) |
|
|
141 | (1) |
|
Class, Structs, Records, or Tuples? |
|
|
142 | (2) |
|
|
144 | (1) |
|
|
144 | (1) |
|
|
144 | (3) |
|
|
147 | (11) |
|
|
158 | (2) |
|
|
160 | (17) |
|
|
177 | (12) |
|
|
189 | (3) |
|
|
192 | (1) |
|
|
192 | (1) |
|
|
193 | (3) |
|
Default Interface Implementation |
|
|
196 | (2) |
|
|
198 | (3) |
|
|
201 | (1) |
|
|
202 | (2) |
|
Partial Types and Methods |
|
|
204 | (2) |
|
|
206 | (1) |
|
|
207 | (20) |
|
|
208 | (2) |
|
|
210 | (2) |
|
|
212 | (2) |
|
Reference Type Constraints |
|
|
214 | (3) |
|
|
217 | (1) |
|
Value Types All the Way Down with Unmanaged Constraints |
|
|
217 | (1) |
|
|
218 | (1) |
|
Other Special Type Constraints |
|
|
218 | (1) |
|
|
218 | (1) |
|
|
219 | (1) |
|
|
220 | (1) |
|
|
221 | (1) |
|
|
222 | (1) |
|
|
223 | (3) |
|
|
226 | (1) |
|
|
227 | (52) |
|
|
227 | (4) |
|
|
231 | (1) |
|
|
232 | (5) |
|
|
237 | (3) |
|
|
240 | (1) |
|
|
241 | (3) |
|
List and Sequence Interfaces |
|
|
244 | (7) |
|
Implementing Lists and Sequences |
|
|
251 | (1) |
|
Implementing IEnumerable<T> with Iterators |
|
|
251 | (5) |
|
|
256 | (1) |
|
|
256 | (1) |
|
Addressing Elements with Index and Range Syntax |
|
|
257 | (1) |
|
|
258 | (2) |
|
|
260 | (3) |
|
Supporting Index and Range in Your Own Types |
|
|
263 | (3) |
|
|
266 | (3) |
|
|
269 | (1) |
|
|
270 | (2) |
|
|
272 | (1) |
|
|
273 | (1) |
|
|
274 | (1) |
|
|
275 | (2) |
|
|
277 | (2) |
|
|
279 | (40) |
|
Inheritance and Conversions |
|
|
281 | (3) |
|
|
284 | (1) |
|
|
285 | (1) |
|
Covariance and Contravariance |
|
|
286 | (6) |
|
|
292 | (1) |
|
The Ubiquitous Methods of System.Object |
|
|
293 | (1) |
|
Accessibility and Inheritance |
|
|
294 | (1) |
|
|
295 | (3) |
|
|
298 | (2) |
|
Inheritance and Library Versioning |
|
|
300 | (6) |
|
Sealed Methods and Classes |
|
|
306 | (1) |
|
|
307 | (1) |
|
Inheritance and Construction |
|
|
308 | (4) |
|
|
312 | (4) |
|
Records, Inheritance, and the with Keyword |
|
|
316 | (1) |
|
|
317 | (1) |
|
|
318 | (1) |
|
|
319 | (44) |
|
|
320 | (2) |
|
|
322 | (2) |
|
Accidentally Defeating the Garbage Collector |
|
|
324 | (3) |
|
|
327 | (3) |
|
|
330 | (6) |
|
|
336 | (3) |
|
Temporarily Suspending Garbage Collections |
|
|
339 | (1) |
|
Accidentally Defeating Compaction |
|
|
340 | (3) |
|
Forcing Garbage Collections |
|
|
343 | (1) |
|
Destructors and Finalization |
|
|
344 | (4) |
|
|
348 | (7) |
|
|
355 | (1) |
|
|
356 | (5) |
|
|
361 | (1) |
|
|
362 | (1) |
|
|
363 | (30) |
|
|
365 | (1) |
|
|
366 | (3) |
|
Failures Detected by the Runtime |
|
|
369 | (1) |
|
|
370 | (1) |
|
|
371 | (2) |
|
|
373 | (1) |
|
|
374 | (2) |
|
|
376 | (1) |
|
|
377 | (2) |
|
|
379 | (2) |
|
|
381 | (3) |
|
|
384 | (1) |
|
|
384 | (3) |
|
|
387 | (2) |
|
|
389 | (2) |
|
|
391 | (2) |
|
9 Delegates, Lambdas, and Events |
|
|
393 | (40) |
|
|
394 | (2) |
|
|
396 | (4) |
|
|
400 | (1) |
|
|
401 | (1) |
|
|
402 | (2) |
|
|
404 | (2) |
|
|
406 | (3) |
|
|
409 | (4) |
|
|
413 | (8) |
|
Lambdas and Expression Trees |
|
|
421 | (2) |
|
|
423 | (2) |
|
Standard Event Delegate Pattern |
|
|
425 | (1) |
|
Custom Add and Remove Methods |
|
|
426 | (3) |
|
Events and the Garbage Collector |
|
|
429 | (1) |
|
|
430 | (1) |
|
Delegates Versus Interfaces |
|
|
431 | (1) |
|
|
432 | (1) |
|
|
433 | (62) |
|
|
434 | (3) |
|
How Query Expressions Expand |
|
|
437 | (2) |
|
Supporting Query Expressions |
|
|
439 | (4) |
|
|
443 | (3) |
|
LINQ, Generics, and IQueryable>T< |
|
|
446 | (2) |
|
|
448 | (2) |
|
|
450 | (3) |
|
|
453 | (3) |
|
|
456 | (3) |
|
|
459 | (1) |
|
|
460 | (3) |
|
|
463 | (2) |
|
Specific Items and Subranges |
|
|
465 | (5) |
|
|
470 | (5) |
|
|
475 | (1) |
|
Whole-Sequence, Order-Preserving Operations |
|
|
476 | (2) |
|
|
478 | (4) |
|
|
482 | (3) |
|
|
485 | (5) |
|
|
490 | (1) |
|
Other LINQ Implementations |
|
|
490 | (1) |
|
|
491 | (1) |
|
|
491 | (1) |
|
|
492 | (1) |
|
|
492 | (1) |
|
|
492 | (1) |
|
|
492 | (3) |
|
|
495 | (66) |
|
|
497 | (1) |
|
|
498 | (1) |
|
|
499 | (8) |
|
Publishing and Subscribing with Delegates |
|
|
507 | (1) |
|
Creating an Observable Source with Delegates |
|
|
507 | (4) |
|
Subscribing to an Observable Source with Delegates |
|
|
511 | (1) |
|
|
512 | (1) |
|
|
512 | (1) |
|
|
512 | (1) |
|
|
513 | (1) |
|
|
513 | (1) |
|
|
513 | (1) |
|
|
514 | (1) |
|
|
514 | (1) |
|
|
515 | (2) |
|
|
517 | (2) |
|
|
519 | (5) |
|
|
524 | (1) |
|
Aggregation and Other Single-Value Operators |
|
|
525 | (1) |
|
|
526 | (1) |
|
|
526 | (1) |
|
|
527 | (2) |
|
|
529 | (6) |
|
|
535 | (2) |
|
|
537 | (1) |
|
|
538 | (1) |
|
|
538 | (1) |
|
|
539 | (2) |
|
|
541 | (1) |
|
|
542 | (1) |
|
|
542 | (2) |
|
|
544 | (1) |
|
|
544 | (1) |
|
|
545 | (1) |
|
|
545 | (1) |
|
IEnumerable<T> and IAsyncEnumerable<T> |
|
|
546 | (1) |
|
|
547 | (2) |
|
|
549 | (2) |
|
|
551 | (1) |
|
|
551 | (2) |
|
|
553 | (1) |
|
|
553 | (1) |
|
|
554 | (1) |
|
|
555 | (1) |
|
|
555 | (1) |
|
|
555 | (1) |
|
|
556 | (1) |
|
|
557 | (1) |
|
|
557 | (1) |
|
Reaqtor---Rx as a Service |
|
|
558 | (1) |
|
|
559 | (2) |
|
|
561 | (30) |
|
|
562 | (1) |
|
|
563 | (1) |
|
|
563 | (1) |
|
|
563 | (1) |
|
|
564 | (2) |
|
|
566 | (3) |
|
|
569 | (1) |
|
|
570 | (4) |
|
|
574 | (1) |
|
Isolation and Plug-ins with AssemblyLoadContext |
|
|
575 | (2) |
|
|
577 | (1) |
|
|
577 | (3) |
|
|
580 | (3) |
|
Version Numbers and Assembly Loading |
|
|
583 | (1) |
|
|
584 | (3) |
|
|
587 | (1) |
|
Target Frameworks and NET Standard |
|
|
588 | (2) |
|
|
590 | (1) |
|
|
591 | (22) |
|
|
592 | (1) |
|
|
593 | (4) |
|
|
597 | (1) |
|
|
597 | (3) |
|
|
600 | (5) |
|
MethodBase, ConstructorInfo, and MethodInfo |
|
|
605 | (2) |
|
|
607 | (1) |
|
|
607 | (1) |
|
|
608 | (1) |
|
|
608 | (1) |
|
|
609 | (2) |
|
|
611 | (2) |
|
|
613 | (24) |
|
|
613 | (3) |
|
|
616 | (2) |
|
Compiler-Handled Attributes |
|
|
618 | (8) |
|
|
626 | (4) |
|
Defining and Consuming Attributes |
|
|
630 | (1) |
|
|
631 | (2) |
|
|
633 | (2) |
|
|
635 | (1) |
|
|
636 | (1) |
|
|
637 | (48) |
|
|
638 | (2) |
|
|
640 | (1) |
|
|
641 | (1) |
|
|
642 | (1) |
|
|
642 | (1) |
|
|
643 | (1) |
|
|
644 | (1) |
|
|
645 | (1) |
|
|
646 | (2) |
|
Random Access and Scatter/Gather I/O Without Stream |
|
|
648 | (1) |
|
|
649 | (1) |
|
TextReader and Text Writer |
|
|
650 | (2) |
|
Concrete Reader and Writer Types |
|
|
652 | (2) |
|
|
654 | (4) |
|
|
658 | (1) |
|
|
658 | (4) |
|
|
662 | (4) |
|
|
666 | (1) |
|
|
667 | (2) |
|
FileInfo, DirectoryInfo, and FileSystemInfo |
|
|
669 | (1) |
|
|
670 | (1) |
|
|
671 | (1) |
|
BinaryReader, BinaryWriter, and BinaryPrimitives |
|
|
672 | (1) |
|
|
673 | (1) |
|
|
674 | (8) |
|
|
682 | (3) |
|
|
685 | (58) |
|
|
685 | (2) |
|
Threads, Variables, and Shared State |
|
|
687 | (3) |
|
|
690 | (3) |
|
|
693 | (1) |
|
|
694 | (3) |
|
Thread Affinity and SynchronizationContext |
|
|
697 | (2) |
|
|
699 | (2) |
|
|
701 | (1) |
|
Monitors and the lock Keyword |
|
|
702 | (7) |
|
|
709 | (2) |
|
|
711 | (1) |
|
|
712 | (3) |
|
|
715 | (1) |
|
|
716 | (1) |
|
|
716 | (1) |
|
|
717 | (1) |
|
|
718 | (2) |
|
|
720 | (2) |
|
Other Class Library Concurrency Support |
|
|
722 | (2) |
|
|
724 | (1) |
|
The Task and Task<T> Classes |
|
|
724 | (6) |
|
|
730 | (2) |
|
|
732 | (2) |
|
|
734 | (1) |
|
|
734 | (2) |
|
Parent/Child Relationships |
|
|
736 | (1) |
|
|
736 | (1) |
|
Other Asynchronous Patterns |
|
|
737 | (1) |
|
|
738 | (1) |
|
|
739 | (1) |
|
|
739 | (2) |
|
|
741 | (1) |
|
|
741 | (1) |
|
|
741 | (2) |
|
17 Asynchronous Language Features |
|
|
743 | (30) |
|
Asynchronous Keywords: async and await |
|
|
744 | (4) |
|
Execution and Synchronization Contexts |
|
|
748 | (2) |
|
Multiple Operations and Loops |
|
|
750 | (6) |
|
|
756 | (2) |
|
Applying async to Nested Methods |
|
|
758 | (1) |
|
|
759 | (4) |
|
|
763 | (3) |
|
|
766 | (1) |
|
Singular and Multiple Exceptions |
|
|
767 | (2) |
|
Concurrent Operations and Missed Exceptions |
|
|
769 | (2) |
|
|
771 | (2) |
|
|
773 | (20) |
|
|
774 | (4) |
|
Representing Sequential Elements with Span<T> |
|
|
778 | (3) |
|
|
781 | (1) |
|
|
781 | (1) |
|
Representing Sequential Elements with Memory<T> |
|
|
782 | (1) |
|
|
782 | (1) |
|
Processing Data Streams with Pipelines |
|
|
783 | (2) |
|
Processing JSON in ASP.NET Core |
|
|
785 | (6) |
|
|
791 | (2) |
Index |
|
793 | |