Essential C# 8.0, 7th Edition

Book description

The Comprehensive, Expert Guide to C# 8.0 for Programmers at All Levels

Welcome to one of the most venerable and trusted franchises you could dream of in the world of C# booksand probably far beyond! . . . Mark is super smart, insists on understanding everything to the core, and has phenomenal insight into how things affect real developers. . . . He goes right to the essence and communicates with great integrityno sugarcoatingand has a keen eye for practical value and real-world problems.

From the Foreword by Mads Torgersen, C# Lead Designer, Microsoft

Essential C# 8.0 is a well-organized, no-fluff guide to C# 8.0 for programmers at all levels of experience. This edition retains all the valuable content of prior editions and adds discussions of null reference types, indices and ranges, enhanced pattern matching, asynchronous stream, and more.

World-class C# expert Mark Michaelis presents a comprehensive tutorial and reference for the entire language, providing an accelerated learning opportunity to achieve expert C# programming skills. He includes key C# 8.0 enhancements, succinct examples to illustrate central constructs, and updated coding guidelines for minimizing bugs and writing code thats easier to evolve. To help you quickly find what you need, there are version-specific indexes of C# 6.0, 7.0, and 8.0 topics and visual icons that identify when each language innovation was introduced.

  • Use structured programming constructs to write functioning code immediately

  • Learn both the complexities and solutions to nullable reference types

  • Thoroughly master C# object constructs, including classes, inheritance, and interfaces

  • Reduce code redundancy with generics, delegates, lambda expressions, and events

  • Take full advantage of collections, including the new standard query operator collection API

  • Make the most of reflection, attributes, and the declarative programming paradigm

  • Improve multithreading with the task-based async pattern and C# 8.0 asynchronous streams

  • Enhance performance through the parallel processing of data and multithreading tasks

  • Program complex types with enhanced pattern matching syntax

  • Interoperate with unmanaged code written in other languages, including C-based APIs

  • Explore the relationship between C# programs and the underlying CLI runtime

Register your product for convenient access to downloads, updates, and/or corrections as they become available. See inside book for details.

Table of contents

  1. Cover Page
  2. About This eBook
  3. Halftitle Page
  4. Title Page
  5. Copyright Page
  6. Dedication Page
  7. Contents at a Glance
  8. Contents
  9. Figures
  10. Tables
  11. Foreword
  12. Preface
  13. Acknowledgments
  14. About the Author
  15. 1. Introducing C#
    1. Hello, World
    2. C# Syntax Fundamentals
    3. Working with Variables
    4. Console Input and Output
    5. Managed Execution and the Common Language Infrastructure
    6. Multiple .NET Frameworks
  16. 2. Data Types
    1. Fundamental Numeric Types
    2. More Fundamental Types
    3. Conversions between Data Types
  17. 3. More with Data Types
    1. Categories of Types
    2. Declaring Types That Allow null
    3. Implicitly Typed Local Variables
    4. Tuples
    5. Arrays
  18. 4. Operators and Flow Control
    1. Operators
    2. Introducing Flow Control
    3. Code Blocks ({})
    4. Code Blocks, Scopes, and Declaration Spaces
    5. Boolean Expressions
    6. Programming with null
    7. Bitwise Operators (<<, >>, |, &, ^, ~)
    8. Control Flow Statements, Continued
    9. Jump Statements
    10. C# Preprocessor Directives
    11. Summary
  19. 5. Methods and Parameters
    1. Calling a Method
    2. Declaring a Method
    3. The using Directive
    4. Returns and Parameters on Main()
    5. Advanced Method Parameters
    6. Recursion
    7. Method Overloading
    8. Optional Parameters
    9. Basic Error Handling with Exceptions
    10. Summary
  20. 6. Classes
    1. Declaring and Instantiating a Class
    2. Instance Fields
    3. Instance Methods
    4. Using the this Keyword
    5. Access Modifiers
    6. Properties
    7. Constructors
    8. Non-Nullable Reference Type Properties with Constructors
    9. Nullable Attributes
    10. Deconstructors
    11. Static Members
    12. Extension Methods
    13. Encapsulating the Data
    14. Nested Classes
    15. Partial Classes
    16. Summary
  21. 7. Inheritance
    1. Derivation
    2. Overriding the Base Class
    3. Abstract Classes
    4. All Classes Derive from System.Object
    5. Pattern Matching with the is Operator
    6. Pattern Matching within a switch Expression
    7. Avoid Pattern Matching When Polymorphism Is Possible
    8. Summary
  22. 8. Interfaces
    1. Introducing Interfaces
    2. Polymorphism through Interfaces
    3. Interface Implementation
    4. Converting between the Implementing Class and Its Interfaces
    5. Interface Inheritance
    6. Multiple Interface Inheritance
    7. Extension Methods on Interfaces
    8. Versioning
    9. Extension Methods versus Default Interface Members
    10. Interfaces Compared with Abstract Classes
    11. Interfaces Compared with Attributes
  23. 9. Value Types
    1. Structs
    2. Boxing
    3. Enums
    4. Summary
  24. 10. Well-Formed Types
    1. Overriding object Members
    2. Operator Overloading
    3. Referencing Other Assemblies
    4. Encapsulation of Types
    5. Defining Namespaces
    6. XML Comments
    7. Garbage Collection
    8. Resource Cleanup
    9. Lazy Initialization
    10. Summary
  25. 11. Exception Handling
    1. Multiple Exception Types
    2. Catching Exceptions
    3. Rethrowing an Existing Exception
    4. General Catch Block
    5. Guidelines for Exception Handling
    6. Defining Custom Exceptions
    7. Rethrowing a Wrapped Exception
    8. Summary
  26. 12. Generics
    1. C# without Generics
    2. Introducing Generic Types
    3. Constraints
    4. Generic Methods
    5. Covariance and Contravariance
    6. Generic Internals
    7. Summary
  27. 13. Delegates and Lambda Expressions
    1. Introducing Delegates
    2. Declaring Delegate Types
    3. Lambda Expressions
    4. Statement Lambdas
    5. Anonymous Methods
    6. Delegates Do Not Have Structural Equality
    7. Outer Variables
    8. Expression Trees
    9. Summary
  28. 14. Events
    1. Coding the Publish–Subscribe Pattern with Multicast Delegates
    2. Understanding Events
    3. Summary
  29. 15. Collection Interfaces with Standard Query Operators
    1. Collection Initializers
    2. What Makes a Class a Collection: IEnumerable
    3. Standard Query Operators
    4. Anonymous Types with LINQ
    5. Summary
  30. 16. LINQ with Query Expressions
    1. Introducing Query Expressions
    2. Query Expressions Are Just Method Invocations
    3. Summary
  31. 17. Building Custom Collections
    1. More Collection Interfaces
    2. Primary Collection Classes
    3. Providing an Indexer
    4. Returning null or an Empty Collection
    5. Iterators
    6. Summary
  32. 18. Reflection, Attributes, and Dynamic Programming
    1. Reflection
    2. nameof Operator
    3. Attributes
    4. Programming with Dynamic Objects
    5. Summary
  33. 19. Introducing Multithreading
    1. Multithreading Basics
    2. Asynchronous Tasks
    3. Canceling a Task
    4. Working with System.Threading
    5. Summary
  34. 20. Programming the Task-Based Asynchronous Pattern
    1. Synchronously Invoking a High-Latency Operation
    2. Asynchronously Invoking a High-Latency Operation Using the TPL
    3. The Task-Based Asynchronous Pattern with async and await
    4. Introducing Asynchronous Return of ValueTask<T>
    5. Asynchronous Streams
    6. IAsyncDisposable and the await using Declaration and Statement
    7. Using LINQ with IAsyncEnumerable
    8. Returning void from an Asynchronous Method
    9. Asynchronous Lambdas and Local Functions
    10. Task Schedulers and the Synchronization Context
    11. async/await with the Windows UI
    12. Summary
  35. 21. Iterating in Parallel
    1. Executing Loop Iterations in Parallel
    2. Running LINQ Queries in Parallel
    3. Summary
  36. 22. Thread Synchronization
    1. Why Synchronization?
    2. Timers
    3. Summary
  37. 23. Platform Interoperability and Unsafe Code
    1. Platform Invoke
    2. Pointers and Addresses
    3. Executing Unsafe Code via a Delegate
    4. Summary
  38. 24. The Common Language Infrastructure
    1. Defining the Common Language Infrastructure
    2. CLI Implementations
    3. .NET Standard
    4. Base Class Library
    5. C# Compilation to Machine Code
    6. Runtime
    7. Assemblies, Manifests, and Modules
    8. Common Intermediate Language
    9. Common Type System
    10. Common Language Specification
    11. Metadata
    12. .NET Native and Ahead of Time Compilation
    13. Summary
  39. Index
  40. Index of 8.0 Topics
  41. Index of 7.0 Topics
  42. Index of 6.0 Topics
  43. Credits
  44. Code Snippets

Product information

  • Title: Essential C# 8.0, 7th Edition
  • Author(s): Mark Michaelis
  • Release date: October 2020
  • Publisher(s): Addison-Wesley Professional
  • ISBN: 9780135972311