C# Playbook
This course will teach you to solve more complex problems in C#. You’ll learn by solving numerous practical problems that require the full range of C# language features, from classes to null values, to exceptions to generics, and more.
What you'll learn
In this course, C# Playbook, you’ll learn to solve more complex problems in C#. You’ll see numerous examples of problems that can arise in real-world apps, and learn how to use C# language features to tackle them. The problems will cover validating method arguments, pattern matching, immutability, instantiating objects correctly, LINQ, async coding, null values, generics, error handling, reflection, interop, and much more. By the end of the course, you’ll have the knowledge to use different C# language features appropriately to solve more complicated problems, taking your C# coding skills to the next level.
Table of contents
- Overview 1m
- Adding Guard Clauses to Methods 4m
- Improving the Guard Clause Code 3m
- Choosing Styles of Property 5m
- Fluent Coding 5m
- Returning Multiple Values with a Value Tuple 3m
- Consuming the Returned Value Tuple 2m
- Returning Multiple Values with out Parameters 3m
- Passing ValueTypes by Reference for Performance 3m
- Comparing in, out, and ref Parameters 4m
- Using sizeof to Decide Whether to Pass by Reference 3m
- Summary 2m
- Overview 2m
- Making Sure Fields Are Initialized 5m
- Initializing Fields up the Class Hierarchy 4m
- Lazy Loading 4m
- Using the Lazy<T> Type 2m
- Implementing a Singleton Class 4m
- Writing a Factory Class: Private Access Required 3m
- Solving the Problem with a Nested Class 2m
- Safely Casting Using Pattern Matching 3m
- Deciding between Struct, Class, Record Struct, and Record Class 4m
- Struct vs. Class Examples 5m
- Summary 2m
- Overview 2m
- Introducing the Demo 2m
- Setting up Dependency Injection 4m
- Using an Interface to Fix the Dependency Injection 4m
- Avoiding Name Clashes with Explicit Interface Implementation 4m
- Explicit Interface Method Implementation: How It Works 3m
- Dependency Injection via Interfaces (Again!) 2m
- Extending an Interface with Default Implementations 3m
- Making the Default Interface Implementation More Useful 4m
- Summary 1m
- Overview 1m
- Making Your Struct Nullable 3m
- Working with Nullable Structs 4m
- Value Type Default Isn't Null 2m
- Enabling Null-checking for Classes 2m
- Using Nullable and Not-nullable Classes 4m
- Nullability: Structs vs. Classes 3m
- What if Nullable Reference Types Are Not Enabled? 2m
- Handling Null or Empty Strings 5m
- Enabling Nullable Reference Types for Existing Code 5m
- Enabling Nullability for Generic Types 1m
- Nullability: Inferring the Author’s Intentions 2m
- ToString() and the Null-forgiving Operator 2m
- Summary 1m
- Overview 1m
- Setting up the Demo 2m
- Removing Duplicates 3m
- Grouping Your Data 4m
- Sorting as You Group Data 2m
- Flattening a List of Lists 4m
- Joining Multiple Lists 4m
- Grouping When You Join Lists 3m
- Calculating an Average in an Inner Loop 3m
- Creating Custom LINQ Extension Methods 5m
- Taking Advantage of Lazy Evaluation 3m
- Destroying Lazy Evaluation with Collections 4m
- Summary 2m
- Overview 1m
- Introducing the Demo: Reading a Problematic JSON File 6m
- Taking Different Actions for Different Errors 5m
- Multiple Catch Blocks: Best Practices 4m
- Defining a Custom Exception 5m
- Using Exception Filters 3m
- Catching an Exception Thrown from Async Code 4m
- Ensuring Cleanup Code Is Always Executed with Finally 3m
- Using as an Alternative to Finally 2m
- Debugging Why an Exception Has Been Thrown 5m
- Exceptions vs. Debug.Assert() 4m
- Summary 1m
- Overview 2m
- Setting up the Demo 4m
- Marking a Method as Obsolete 4m
- Writing a Custom Attribute 4m
- Using Reflection to Find the Attributes on a Type 5m
- Using Attributes to Create Friendly Text for Enum Values 3m
- Consuming Attributes on Fields: Implementing Enum Friendly Text 3m
- Using Reflection to Obtain the Property Values of an Instance 5m
- Identifying Whether a Class Is Immutable 5m
- Summary 2m
- Overview 2m
- Running an Async Operation 5m
- Using WhenAll to Await Async Operations 3m
- Await Can’t Launch Parallel Tasks 3m
- Don’t Mix the UI into the Async Task 4m
- Using Progress to Show Results as Each Task Completes 3m
- Protecting Shared Data with a Lock Statement 6m
- Using Thread-safe Types to Avoid Explicit Locking 3m
- Avoiding the Need to Synchronize Threads 3m
- Generating an Async Stream 5m
- Consuming an Async Stream 2m
- Summary 2m
- Overview 1m
- External Data Prevents Testing 4m
- Trying to Test without Mocking 2m
- Using Dependency Injection to Make Types Mock-friendly 3m
- Implementing Mocking to Remove the External Data Dependency 4m
- Testing: Static Methods without Dependencies 2m
- The Problem with Static Methods with Dependencies! 3m
- Solving the Static External Dependency 4m
- Choosing Parameter Values to Test a Method 4m
- Writing a Data-driven Test in NUnit 3m
- Summary 1m
- Overview: Introducing the Windows API 4m
- Calling an Unmanaged API Method: MessageBox() 3m
- P/Invoke and Marshalling Data 4m
- Distinguishing ANSI and Unicode API Functions 4m
- Custom Marshalling Data 4m
- Displaying Devices with EnumDisplayDevicesW() 5m
- Calling a VB Method 4m
- Calling an F# Method 3m
- The C# / F# Type Mismatch 4m
- Summary 2m