What is Lazy Injection?

Updated Apr 28, 2026

Short answer

Lazy Injection delays the instantiation of a dependency until it is actually accessed for the first time.

Deep explanation

Using a wrapper like Lazy<T> or a factory function () => T, the DI container injects the proxy or factory instead of the concrete object. The heavy object is only constructed if the specific code path requiring it is executed. It saves memory and startup time.

Real-world example

A complex reporting service that is rarely used. Injecting it lazily means the application doesn't pay the cost of building it until a user clicks 'Generate Report'.

Common mistakes

  • Using Lazy injection everywhere prematurely, which complicates the codebase and hides actual dependency graphs.

Follow-up questions

  • How does Lazy Injection help with Circular Dependencies?

More Dependency Injection interview questions

View all →