C# Cookbook: Modern Recipes for Professional Developers
Even if you're familiar with C# syntax, knowing how to combine various language features is a critical skill when you're building applications. This 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#.

Recipes in this book will help you:

  • Set up your project, manage object lifetime, and establish patterns
  • Improve code quality through maintainability, error prevention, and correct syntax
  • Use LINQ to Objects for in-memory data manipulation and querying
  • Understand the differences between dynamic programming and reflection
  • Apply several async programming features you may not be aware of
  • Work with data using newer libraries and algorithms
  • Learn different ways to use new C# features, such as pattern matching and records
1139108470
C# Cookbook: Modern Recipes for Professional Developers
Even if you're familiar with C# syntax, knowing how to combine various language features is a critical skill when you're building applications. This 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#.

Recipes in this book will help you:

  • Set up your project, manage object lifetime, and establish patterns
  • Improve code quality through maintainability, error prevention, and correct syntax
  • Use LINQ to Objects for in-memory data manipulation and querying
  • Understand the differences between dynamic programming and reflection
  • Apply several async programming features you may not be aware of
  • Work with data using newer libraries and algorithms
  • Learn different ways to use new C# features, such as pattern matching and records
65.99 In Stock
C# Cookbook: Modern Recipes for Professional Developers

C# Cookbook: Modern Recipes for Professional Developers

by Joe Mayo
C# Cookbook: Modern Recipes for Professional Developers

C# Cookbook: Modern Recipes for Professional Developers

by Joe Mayo

Paperback

$65.99 
  • SHIP THIS ITEM
    In stock. Ships in 1-2 days.
  • PICK UP IN STORE

    Your local store may have stock of this item.

Related collections and offers


Overview

Even if you're familiar with C# syntax, knowing how to combine various language features is a critical skill when you're building applications. This 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#.

Recipes in this book will help you:

  • Set up your project, manage object lifetime, and establish patterns
  • Improve code quality through maintainability, error prevention, and correct syntax
  • Use LINQ to Objects for in-memory data manipulation and querying
  • Understand the differences between dynamic programming and reflection
  • Apply several async programming features you may not be aware of
  • Work with data using newer libraries and algorithms
  • Learn different ways to use new C# features, such as pattern matching and records

Product Details

ISBN-13: 9781492093695
Publisher: O'Reilly Media, Incorporated
Publication date: 11/02/2021
Pages: 325
Product dimensions: 7.00(w) x 9.19(h) x 0.69(d)

About the Author

Joe Mayo is an author, instructor, and independent consultant who has been working with C# and .NET since its announcement in the summer of the year 2000. As an independent consultant, he’s worked with a variety of organizations from startup to fortune 500 enterprise. His experience in this journey includes desktop, web, mobile, cloud, and AI technologies. In addition to practical hands-on application, he’s also taught C# and .NET for many years via in-person, live video, and recorded video courses. His top open-source project is LINQ to Twitter (on GitHub), with over 1,000,000 NuGet downloads. When Joe isn’t serving valued customers, he contributes to the community through Q&A forums, presenting, and (one of his favorite pastimes) writing.

Table of Contents

Preface vii

1 Constructing Types and Apps 1

1.1 Managing Object End-of-Lifetime 2

1.2 Removing Explicit Dependencies 6

1.3 Delegating Object Creation to a Class 10

1.4 Delegating Object Creation to a Method 12

1.5 Designing Application Layers 16

1.6 Returning Multiple Values from a Method 21

1.7 Converting from Legacy to Strongly Typed Classes 24

1.8 Making Classes Adapt to Your Interface 28

1.9 Designing a Custom Exception 30

1.10 Constructing Objects with Complex Configuration 33

2 Coding Algorithms 37

2.1 Processing Strings Efficiently 38

2.2 Simplifying Instance Cleanup 41

2.3 Keeping Logic Local 43

2.4 Operating on Multiple Classes the Same Way 45

2.5 Checking for Type Equality 48

2.6 Processing Data Hierarchies 52

2.7 Converting from/to Unix Time 55

2.8 Caching Frequently Requested Data 58

2.9 Delaying Type Instantiation 60

2.10 Parsing Data Files 63

3 Ensuring Quality 67

3.1 Writing a Unit Test 68

3.2 Versioning Interfaces Safely 72

3.3 Simplifying Parameter Validation 74

3.4 Protecting Code from NullReferenceException 76

3.5 Avoiding Magic Strings 81

3.6 Customizing Class String Representation 83

3.7 Rethrowing Exceptions 85

3.8 Managing Process Status 90

3.9 Building Resilient Network Connections 91

3.10 Measuring Performance 94

4 Querying with LINQ 97

4.1 Transforming Object Shape 98

4.2 Joining Data 100

4.3 Performing Left Joins 104

4.4 Grouping Data 108

4.5 Building Incremental Queries 111

4.6 Querying Distinct Objects 116

4.7 Simplifying Queries 120

4.8 Operating on Sets 123

4.9 Building a Query Filter with Expression Trees 127

4.10 Querying in Parallel 134

5 Implementing Dynamic and Reflection 139

5.1 Reading Attributes with Reflection 140

5.2 Accessing Type Members with Reflection 144

5.3 Instantiating Type Members with Reflection 150

5.4 Invoking Methods with Reflection 159

5.5 Replacing Reflection with Dynamic Code 162

5.6 Performing Interop with Office Apps 164

5.7 Creating an Inherently Dynamic Type 169

5.8 Adding and Removing Type Members Dynamically 172

5.9 Calling Python Code from C# 174

5.10 Calling C# Code from Python 177

6 Programming Asynchronously 181

6.1 Creating Async Console Applications 182

6.2 Reducing Memory Allocations for Async Return Values 184

6.3 Creating Async Iterators 187

6.4 Writing Safe Async Libraries 190

6.5 Updating Progress Asynchronously 193

6.6 Calling Synchronous Code from Async Code 195

6.7 Waiting for Parallel Tasks to Complete 198

6.8 Handling Parallel Tasks as They Complete 201

6.9 Cancelling Async Operations 206

6.10 Disposing of Async Resources 209

7 Manipulating Data 215

7.1 Generating Password Hashes 215

7.2 Encrypting and Decrypting Secrets 219

7.3 Hiding Development Secrets 222

7.4 Producing JSON 224

7.5 Consuming JSON 227

7.6 Working with JSON Data 232

7.7 Consuming XML 239

7.8 Producing XML 243

7.9 Encoding and Decoding URL Parameters 246

7.10 Flexible DateTime Reading 249

8 Matching with Patterns 253

8.1 Converting Instances Safely 253

8.2 Catching Filtered Exceptions 257

8.3 Simplifying Switch Assignments 258

8.4 Switching on Property Values 261

8.5 Switching on Tuples 263

8.6 Switching on Position 266

8.7 Switching on Value Ranges 269

8.8 Switching with Complex Conditions 270

8.9 Using Logical Conditions 273

8.10 Switching on Type 275

9 Examining Recent C# Language Highlights 279

9.1 Simplifying Application Startup 280

9.2 Reducing Instantiation Syntax 281

9.3 Initializing Immutable State 284

9.4 Creating Immutable Types 286

9.5 Simplifying Immutable Type Assignments 291

9.6 Designing for Record Reuse 292

9.7 Returning Different Method Override Types 294

9.8 Implementing Iterators as Extension Methods 297

9.9 Slicing Arrays 299

9.10 Initializing Entire Modules 301

Summary 305

Index 307

From the B&N Reads Blog

Customer Reviews