ASP.NET Core Interview Question #17

What is IConfiguration?

ASP.NET Core Fundamentals Junior Beginner

Quick Interview Answer

IConfiguration provides key/value access to the application's combined configuration sources. It supports hierarchical keys and sections and can be injected into application services.

Detailed Explanation

IConfiguration provides key/value access to the application's combined configuration sources. It supports hierarchical keys and sections and can be injected into application services.

For groups of related settings, strongly typed options are generally preferable because they provide clearer contracts and type-safe access.

Code Example

public class ReportService
{
    private readonly IConfiguration _configuration;

    public ReportService(IConfiguration configuration)
    {
        _configuration = configuration;
    }
}