Even if you’re familiar with C# syntax, knowing how to combine various language features is a critical skill when building applications. This handy cookbook is packed full of recipes to help you solve issues for C# programming tasks you’re likely to encounter. You’ll learn tried-and-true techniques to help you achieve greater productivity and improve the quality of your code.
Author and independent consultant Joe Mayo shares some of the most important practices you’ll need to be successful as a C# developer. Each section of this cookbook describes some useful facet of the C# programming language. These recipes–the result of many years of experience–are proven concepts for solving real-world problems with C#.
- Learn new techniques for using the latest features of C# 9.0
- Employ patterns for solving a wide selection of problems
- Work with recipes for important C# coding scenarios
- Reuse code that solves common problems
- Increase your knowledge of C# programming
- Improve the quality of your applications
Preface Why I Wrote This Book Who This Book Is For How This Book Is Organized Conventions Used in This Book Using Code Examples O’Reilly Online Learning How to Contact Us Acknowledgments 1. Constructing Types and Apps 1.1. Managing Object End-of-Lifetime 1.2. Removing Explicit Dependencies 1.3. Delegating Object Creation to a Class 1.4. Delegating Object Creation to a Method 1.5. Designing Application Layers 1.6. Returning Multiple Values from a Method 1.7. Converting from Legacy to Strongly Typed Classes 1.8. Making Classes Adapt to Your Interface 1.9. Designing a Custom Exception 1.10. Constructing Objects with Complex Configuration 2. Coding Algorithms 2.1. Processing Strings Efficiently 2.2. Simplifying Instance Cleanup 2.3. Keeping Logic Local 2.4. Operating on Multiple Classes the Same Way 2.5. Checking for Type Equality 2.6. Processing Data Hierarchies 2.7. Converting from/to Unix Time 2.8. Caching Frequently Requested Data 2.9. Delaying Type Instantiation 2.10. Parsing Data Files 3. Ensuring Quality 3.1. Writing a Unit Test 3.2. Versioning Interfaces Safely 3.3. Simplifying Parameter Validation 3.4. Protecting Code from NullReferenceException 3.5. Avoiding Magic Strings 3.6. Customizing Class String Representation 3.7. Rethrowing Exceptions 3.8. Managing Process Status 3.9. Building Resilient Network Connections 3.10. Measuring Performance 4. Querying with LINQ 4.1. Transforming Object Shape 4.2. Joining Data 4.3. Performing Left Joins 4.4. Grouping Data 4.5. Building Incremental Queries 4.6. Querying Distinct Objects 4.7. Simplifying Queries 4.8. Operating on Sets 4.9. Building a Query Filter with Expression Trees 4.10. Querying in Parallel 5. Implementing Dynamic and Reflection 5.1. Reading Attributes with Reflection 5.2. Accessing Type Members with Reflection 5.3. Instantiating Type Members with Reflection 5.4. Invoking Methods with Reflection 5.5. Replacing Reflection with Dynamic Code 5.6. Performing Interop with Office Apps 5.7. Creating an Inherently Dynamic Type 5.8. Adding and Removing Type Members Dynamically 5.9. Calling Python Code from C# 5.10. Calling C# Code from Python 6. Programming Asynchronously 6.1. Creating Async Console Applications 6.2. Reducing Memory Allocations for Async Return Values 6.3. Creating Async Iterators 6.4. Writing Safe Async Libraries 6.5. Updating Progress Asynchronously 6.6. Calling Synchronous Code from Async Code 6.7. Waiting for Parallel Tasks to Complete 6.8. Handling Parallel Tasks as They Complete 6.9. Cancelling Async Operations 6.10. Disposing of Async Resources 7. Manipulating Data 7.1. Generating Password Hashes 7.2. Encrypting and Decrypting Secrets 7.3. Hiding Development Secrets 7.4. Producing JSON 7.5. Consuming JSON 7.6. Working with JSON Data 7.7. Consuming XML 7.8. Producing XML 7.9. Encoding and Decoding URL Parameters 7.10. Flexible DateTime Reading 8. Matching with Patterns 8.1. Converting Instances Safely 8.2. Catching Filtered Exceptions 8.3. Simplifying Switch Assignments 8.4. Switching on Property Values 8.5. Switching on Tuples 8.6. Switching on Position 8.7. Switching on Value Ranges 8.8. Switching with Complex Conditions 8.9. Using Logical Conditions 8.10. Switching on Type 9. Examining Recent C# Language Highlights 9.1. Simplifying Application Startup 9.2. Reducing Instantiation Syntax 9.3. Initializing Immutable State 9.4. Creating Immutable Types 9.5. Simplifying Immutable Type Assignments 9.6. Designing for Record Reuse 9.7. Returning Different Method Override Types 9.8. Implementing Iterators as Extension Methods 9.9. Slicing Arrays 9.10. Initializing Entire Modules Summary Index
How to download source code?
1. Go to:
2. Search the book title:
C# Cookbook: Modern Recipes for Professional Developers, sometime you may not get the results, please search the main title
3. Click the book title in the search results
Publisher resources section, click
Download Example Code.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.