- Course
C# 14 Dependency Injection
Manually managing code dependencies is difficult. This course will teach you to use the built-in .NET dependency injection container to instantiate classes, resolve dependencies, and control lifetimes, so you can focus on implementing business logic.
- Course
C# 14 Dependency Injection
Manually managing code dependencies is difficult. This course will teach you to use the built-in .NET dependency injection container to instantiate classes, resolve dependencies, and control lifetimes, so you can focus on implementing business logic.
Get started today
Access this course and other top-rated tech content with one of our business plans.
Try this course for free
Access this course and other top-rated tech content with one of our individual plans.
This course is included in the libraries shown below:
- Core Tech
What you'll learn
In any non-trivial C# application with multiple classes, you will quickly face the question of how to provide your classes with their dependencies. In this course, C# 14 Dependency Injection, you’ll gain the ability to use the .NET built-in dependency injection (DI) container to register services, resolve dependencies and control instance lifetimes. First, you’ll explore the IServiceCollection and IServiceProvider types; how to register and resolve types and manage reuse of instances by configuring their lifetimes. Next, you’ll discover how to manage application configuration, inject HttpClient, and manage multiple implementations of the same interface using DI. Finally, you’ll learn how to handle more complex situations like working with factories, IEnumerable, Lazy, ahead-of-time compilation, convenience registrations, and how to avoid the Service Locator pattern. When you’re finished with this course, you’ll have the skills and knowledge of the .NET built-in dependency injection container needed to design large applications using the .NET DI container with predictable construction and lifetime behavior.