What is the use of dependency injection in C# ?
Please don't provide any links.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pradeep SahooRank #489 · 5.1K reputationPosted Nov 9, 2016, 11:20 PM EST
Sreekanth ReddyRank #726 · 3.2K reputationPosted Nov 9, 2016, 11:24 PM EST
Pradeep Sahoo
geetha geethaRank #7,130 · 248 reputationPosted Nov 22, 2021, 9:10 AM EST
Shweta LodhaRank #31 · 39.8K reputationPosted Nov 22, 2021, 7:11 PM EST
It helps you to define your code in a more loosely coupled manner. So, rather than caller instantiating a new object (in C#, instantiation done using new keyword), someone else (DI container) does this for him and caller will just take a responsibility to make a call. Most common practise for achieving this is by using interfaces.