What is IoC in .NET [duplicate]

2019-02-10 23:24发布

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#?

1条回答
虎瘦雄心在
2楼-- · 2019-02-10 23:55

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!

查看更多
登录 后发表回答