Skip to content

devnareshkumar/DependencyInjection-Examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Dependency Injection / Inversion of Control - C# Examples

This repository contains practical examples demonstrating the Dependency Injection design pattern and Inversion of Control principle in C#.

Structure

  • BadExample/ - Demonstrates tightly coupled code that violates DI/IoC principles
  • GoodExample/ - Shows proper implementation of Dependency Injection

Requirements

  • .NET 8.0 SDK or later
  • Visual Studio 2022, VS Code, or Rider

How to Run

BadExample (Tightly Coupled)

cd DependencyInjection-Examples/BadExample
dotnet run

GoodExample (Dependency Injection)

cd DependencyInjection-Examples/GoodExample
dotnet run

Key Concepts Demonstrated

  1. Tight Coupling vs Loose Coupling
  2. Constructor Injection
  3. Dependency on Abstractions (Interfaces)
  4. Single Responsibility Principle
  5. Testability and Flexibility

Learn More

Read the full article: [Link to C# Corner article]

Author

Your Name
C# Corner: [Your profile link]
GitHub: [Your GitHub]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages