Whilst doom scrolling Twitter last night, I came across a tweet by a Norweigan software developer named KarlSolgard; he tweeted about a feature of .NET Core Dependency Injection that I was unaware existed.
#dotnet tip:
— Karl 🔥 (@KarlSolgard) January 21, 2022
You can register services with same interface and inject them as a list in ctor pic.twitter.com/pa8hhSGIsg
Injecting a class or a factory is something that every .NET developer has come to know; however, you can inject an IEnumerable of something. By registering multiple implementations of an interface, your classes can ask for an array of concrete implementations of that interface.