C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
Java
Learn iOS Programming
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
2
Reply
What is dependency injection in C#?
Sachin Kumar
13y
2.4k
0
Reply
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Submit
Dependency Injection (DI) is a design pattern that demonstrates how to create loosely coupled classes. Typically, if Class1 and Class2 were loosely coupled, Class1 would have a reference to an interface instead of a direct binary reference to Class2. For Ex.. public class Class1 {public IClass2 Class2 { get; set; } }public interface IClass2 { }public class Class2 : IClass2 { }
Rajendra Tripathy
11y
1
Dependency injection is a way of implementing inversion of control. There are four main method to implement DI. 1.Constructor methodology 2.Getter and Setter 3.Interface based DI 4.Service Locator.
Akshay Patel
13y
0
Define XLST in C#?
What is the difference between ref and out keywords in Method in C#?
Message