944,118 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 748
  • C# RSS
Nov 8th, 2009
0

Using Interface and interface members in C#

Expand Post »
What is the difference between following declarations:
C# Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 35
Solved Threads: 6
Junior Poster
nccsbim071 is offline Offline
128 posts
since Jul 2009
Nov 8th, 2009
0
Re: Using Interface and interface members in C#
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 .
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Nov 9th, 2009
0
Re: Using Interface and interface members in C#
thanks sknake
Reputation Points: 35
Solved Threads: 6
Junior Poster
nccsbim071 is offline Offline
128 posts
since Jul 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Small error in simple XNA app
Next Thread in C# Forum Timeline: not able read special charactered strings -EXCEL to DataSet-C#





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC