To extend the answer to robin:
IUserRepository _user = new UserRepository();
With dependency injection:
IUserRepository _user;// you will not do anything else.
Based on a configuration somewhere else, the dependency injection infrastructure you are using will take care of creating the right instance for you. This is when management accesses from your code. You do not arbitrarily create any instance from your code.
Why!? Why would you do this?
One of the main advantages is testing, when you run tests, you can configure your IUserRepository fake.
source share