6

Possible Duplicate:
What is Inversion of Control?

I am not familiar with Inversion of Control (IoC). What is IoC and how can applications benefit from using IOC. How is it implemented in .NET with C#?

Community
  • 1
  • 1
Thomas
  • 33,544
  • 126
  • 357
  • 626
  • 2
    Please search for existing questions/answers before you post a new question - this topic has already been covered in some detail. – John Parker Jan 21 '11 at 13:28
  • Inversion of Control (IoC) and dependency injection (DI) patterns are there to help remove dependencies from your code. – Ricardo Sanchez Sep 16 '14 at 23:05

1 Answers1

5

If you have a set of classes that depend on eachother, it's difficult to replace some class for another (better/cheaper/faster) class that does the same job. In order to make your code more flexible, you can use dependency injection.

An easy to use DI framework for C# is Ninject. They have a very understandable tutorial about this subject.

Links:

http://ninject.org/learn

http://blog.andresays.org/2010/10/dependency-injection-with-ninject-and-asp-net-mvc/

Good luck!

Dirk
  • 2,167
  • 2
  • 20
  • 29