0

What is the difference between following declarations:

WebUserService.Service.IUserService userService = new WebUserService.Service.UserService();
WebUserService.Service.UserService userService = new WebUserService.Service.UserService();

I want to know the difference in usage and the the one that is most efficient in terms of programming in C#.

Edited by nccsbim071: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by nccsbim071
0

The only difference is that you are holding on to a reference of the interface versus the class. The class implements more functionality than the interface but you can also cast the interface reference to the class and still call any method. As far as efficiency there is no difference. Both lines are instantiating a UserService .

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.