---
title: "What is Dependency Injection (DI)?"  
description: "What is Dependency Injection (DI)?"  
author: "Anubhav Sharma"  
published: 2026-03-18  
updated: 2026-03-18  
canonical: https://www.mindstick.com/interview/34477/what-is-dependency-injection-di  
category: "asp.net core"  
tags: ["asp.net core"]  
reading_time: 1 minute  

---

# What is Dependency Injection (DI)?

**Dependency Injection** is a design pattern used to **achieve loose coupling between classes**.

ASP.NET Core has **built-in DI container**.

Example:

```plaintext
services.AddScoped<IUserService, UserService>();
```

Service lifetimes:

- **Transient** – new instance every time
- **Scoped** – one instance per request
- **Singleton** – one instance for application lifetime

## Answers

### Answer by Anubhav Sharma

**Dependency Injection** is a design pattern used to **achieve loose coupling between classes**.

ASP.NET Core has **built-in DI container**.

Example:

```plaintext
services.AddScoped<IUserService, UserService>();
```

Service lifetimes:

- **Transient** – new instance every time
- **Scoped** – one instance per request
- **Singleton** – one instance for application lifetime


---

Original Source: https://www.mindstick.com/interview/34477/what-is-dependency-injection-di

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
