Essential C# 7.0, Sixth Edition

Book description

The Comprehensive, Expert Guide to C# Language Programming

 

"This book has been a classic for years, and remains one of the most venerable and trusted titles in the world of C# content, and 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 integrity-no sugarcoating-and has a keen eye for practical value and real-world problems."

Mads Torgersen, C# Program Manager, Microsoft

Essential C# 7.0 is a well-organized, no-fluff guide to C# 7.0 for programmers at all levels of experience. Reflecting the most important C# features from 3.0 through 7.0 and including modern programming patterns, it will help you write code that's simple, powerful, robust, secure, and maintainable.

 

Author Mark Michaelis is a world-class C# expert: a long-time Microsoft MVP and Regional Director who also has served on Microsoft's C# design review team. He presents a comprehensive tutorial and reference for the entire language, including expert coverage of key C# 7.0 enhancements, C# 7.0's use with .NET Core/.NET Standard, and cross-platform compilation. He illustrates key C# constructs with succinct examples, and presents best-practice coding guidelines. To help you maintain existing code, separate indexes provide version-specific answers for C# 5.0, 6.0, and 7.0, and visual icons show when each language innovation was introduced.

  • Make the most of C# 7.0 enhancements, including tuples, deconstructors, pattern matching, local functions, and ref returns
  • Work efficiently with C# data types, operators, control flow, methods, and parameters
  • Write more robust code with C# object-oriented constructs
  • Implement reliable, effective exception handling
  • Reduce code complexity with generics, delegates, lambda expressions, and events
  • Leverage advanced dynamic and declarative programming techniques
  • Query diverse data collections using LINQ with query expressions
  • Create custom collections that operate against business objects
  • Access .NET collections via collection interfaces and standard query operators
  • Master multithreading and synchronization, including the async/await paradigm
  • Optimize performance and interoperability with P/Invoke and unsafe code
  • Run your code on Linux or macOS with C# 7.0 cross-platform compilation
  • Includes C# 7.1, 7.2, and 7.3 language enhancements

This guide offers you a complete foundation for successful development with modern versions of the C# language in any project or environment. ..

Table of contents

  1. Cover Page
  2. Title Page
  3. Dedication Page
  4. Contents at a Glance
  5. Contents
  6. Figures
  7. Tables
  8. Foreword
  9. Preface
    1. Target Audience for This Book
    2. Features of This Book
    3. How This Book Is Organized
  10. Acknowledgments
  11. About the Author
    1. About the Technical Editor
  12. 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
    7. Summary
  13. 2. Data Types
    1. Fundamental Numeric Types
    2. More Fundamental Types
    3. null and void
    4. Conversions between Data Types
    5. Summary
  14. 3. More with Data Types
    1. Categories of Types
    2. Nullable Modifier
    3. Tuples
    4. Arrays
    5. Summary
  15. 4. Operators and Control Flow
    1. Operators
    2. Introducing Flow Control
    3. Code Blocks ({})
    4. Code Blocks, Scopes, and Declaration Spaces
    5. Boolean Expressions
    6. Bitwise Operators (<<, >>, |, &, ^, ~)
    7. Control Flow Statements, Continued
    8. Jump Statements
    9. C# Preprocessor Directives
    10. Summary
  16. 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
  17. 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. Static Members
    9. Extension Methods
    10. Encapsulating the Data
    11. Nested Classes
    12. Partial Classes
    13. Summary
  18. 7. Inheritance
    1. Derivation
    2. Overriding the Base Class
    3. Abstract Classes
    4. All Classes Derive from System.Object
    5. Verifying the Underlying Type with the is Operator
    6. Pattern Matching with the is Operator
    7. Pattern Matching within a switch Statement
    8. Conversion Using the as Operator
    9. Summary
  19. 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. Implementing Multiple Inheritance via Interfaces
    9. Versioning
    10. Interfaces Compared with Classes
    11. Interfaces Compared with Attributes
    12. Summary
  20. 9. Value Types
    1. Structs
    2. Boxing
    3. Enums
    4. Summary
  21. 10. Well-Formed Types
    1. Overriding object Members
    2. Operator Overloading
    3. Referencing Other Assemblies
    4. Defining Namespaces
    5. XML Comments
    6. Garbage Collection
    7. Resource Cleanup
    8. Lazy Initialization
    9. Summary
  22. 11. Exception Handling
    1. Multiple Exception Types
    2. Catching Exceptions
    3. General Catch Block
    4. Guidelines for Exception Handling
    5. Defining Custom Exceptions
    6. Rethrowing a Wrapped Exception
    7. Summary
  23. 12. Generics
    1. C# without Generics
    2. Introducing Generic Types
    3. Constraints
    4. Generic Methods
    5. Covariance and Contravariance
    6. Generic Internals
    7. Summary
  24. 13. Delegates and Lambda Expressions
    1. Introducing Delegates
    2. Declaring Delegate Types
    3. Lambda Expressions
    4. Anonymous Methods
    5. Summary
  25. 14. Events
    1. Coding the Publish-Subscribe Pattern with Multicast Delegates
    2. Understanding Events
    3. Summary
  26. 15. Collection Interfaces with Standard Query Operators
    1. Collection Initializers
    2. What Makes a Class a Collection: IEnumerable<T>
    3. Standard Query Operators
    4. Anonymous Types with LINQ
    5. Summary
  27. 16. LINQ with Query Expressions
    1. Introducing Query Expressions
    2. Query Expressions Are Just Method Invocations
    3. Summary
  28. 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
  29. 18. Reflection, Attributes, and Dynamic Programming
    1. Reflection
    2. nameof Operator
    3. Attributes
    4. Programming with Dynamic Objects
    5. Summary
  30. 19. Multithreading
    1. Multithreading Basics
    2. Working with System.Threading
    3. Asynchronous Tasks
    4. Canceling a Task
    5. The Task-based Asynchronous Pattern
    6. Executing Loop Iterations in Parallel
    7. Running LINQ Queries in Parallel
    8. Summary
  31. 20. Thread Synchronization
    1. Why Synchronization?
    2. Timers
    3. Summary
  32. 21. Platform Interoperability and Unsafe Code
    1. Platform Invoke
    2. Pointers and Addresses
    3. Executing Unsafe Code via a Delegate
    4. Summary
  33. 22. 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
  34. Index
  35. Index of 7.0 Topics
  36. Index of 6.0 Topics
  37. Index of 5.0 Topics
  38. Credits
  39. Code Snippets

Product information

  • Title: Essential C# 7.0, Sixth Edition
  • Author(s): Mark Michaelis
  • Release date: June 2018
  • Publisher(s): Addison-Wesley Professional
  • ISBN: 9781509303595