With ASP.NET, you get built-in dependency injection. In a console application, it’s not there out of the box, but it’s ridiculously simple to get started.
Read more about it here.
Read all about the various options and lifetimes in the Microsoft documentation
View code on GitHub