We all know that we can get services by injecting them directly in the constructor of the class and consume them as we want.
but imagine that you are developing an a generic component in which this component receive the name of service that will be used to get some data for this component, so how we can have an instance for that service as we don’t know its type and we only have its name?
By default, .Net allow us to get instances for registered services using the constructor or by using IServiceProvider GetService() and GetRequiredService() methods, but in order to use these methods we have to know the type of the service which it is not the case here!