.NET 8 - Keyed service dependency injection container support | Programming Tips 💡
.NET 8 -Keyed service dependency injection container support
Keyed services are useful when you have an interface/service with multiple implementations that you want to use in your app. What's more, you need to use each of those implementations in different places in your app.
Sample: var builder = WebApplication.CreateBuilder(args); builder.Services.AddKeyedSingleton("sms"); builder.Services.AddKeyedSingleton("email"); builder.Services.AddKeyedSingleton("push");