Using Interface and interface members in C#

Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jul 2009
Posts: 94
Reputation: nccsbim071 is an unknown quantity at this point 
Solved Threads: 6
nccsbim071's Avatar
nccsbim071 nccsbim071 is offline Offline
Junior Poster in Training

Using Interface and interface members in C#

 
0
  #1
Nov 8th, 2009
What is the difference between following declarations:
  1. WebUserService.Service.IUserService userService = new WebUserService.Service.UserService();
  2. 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#.
Last edited by nccsbim071; Nov 8th, 2009 at 2:33 am.
My Personnel Blog:dotnetworker.blogspot.com
My Company:http://www.bizpersonnel.com
Blog:http://bizpersonnel.wordpress.com
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,442
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 626
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast
 
0
  #2
Nov 8th, 2009
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 .
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 94
Reputation: nccsbim071 is an unknown quantity at this point 
Solved Threads: 6
nccsbim071's Avatar
nccsbim071 nccsbim071 is offline Offline
Junior Poster in Training
 
0
  #3
Nov 9th, 2009
thanks sknake
My Personnel Blog:dotnetworker.blogspot.com
My Company:http://www.bizpersonnel.com
Blog:http://bizpersonnel.wordpress.com
Reply With Quote Quick reply to this message  
Reply

Tags
interface

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 267 | Replies: 2
Thread Tools Search this Thread



Tag cloud for interface
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC