473,809 Members | 2,708 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with the difference between "Implements " and "Inherits"

What would the difference be between the following two:

public class Foo : IList<string>
{
....
}

public class Foo : List<string>
{
....
}

Thanks,
Tom P.
Jul 24 '08 #1
4 2276
In the first one, Foo would have to manually implement all the members
defined by IList<string>.

In the second one, Foo would already come complete with all the
implementation that exists in List<string>, and you could just add
additional functionality on top of it.

--
Adam Clauss
"Tom P." <pa***********@ gmail.comwrote in message
news:01******** *************** ***********@w1g 2000prk.googleg roups.com...
What would the difference be between the following two:

public class Foo : IList<string>
{
...
}

public class Foo : List<string>
{
...
}

Thanks,
Tom P.

Jul 24 '08 #2
Tom P. wrote:
What would the difference be between the following two:

public class Foo : IList<string>
{
...
}

public class Foo : List<string>
{
...
}
The first only inherit the interface. The second inherit
only the interface and the implementation.

But I would be careful with the second - it is easy to
become coupled with the internals of List.

Arne
Jul 24 '08 #3
When a class (type) is derived from another class(type) such that it inherits all the members of the base type it is Implementation Inheritance.
When a type (class or a struct) inherits only the signatures of the functions from another type it is Interface Inheritance.
In general Classes can be derived from another class, hence support Implementation inheritance. At the same time Classes can also be derived from one or more interfaces. Hence they support Interface inheritance.
Source: Exforsys
Jul 26 '08 #4
(implementation and interface inheritance)

And your point?

Marc
Jul 26 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2377
by: David Elliott | last post by:
I have a Collection that inherits from CollectionBase and Implements IBindingList which I have bound to a DataGrid. So far everything works fine. However, I am missing one piece to the IBindingList that I haven't figured out yet, how to determine which DataGrid column header I clicked on so I can do a custom sort. Right now the sort is rotating just to see that everything works. There are two pieces of the IBindingList that I didn't...
9
2696
by: Max Weebler | last post by:
Hi, I have a datagrid built that has an alternating item style that sets the backcolor and ForeColor of its rows. I have 4 template columns. One of them has a LinkButton embedded in it to perform updates. All the styles that are set are being followed by all templated columns with the exception for the update column. The update column does set the BackColor appropriately but when setting its ForeColor the LinkButton's color is blue and...
11
2220
by: Antony | last post by:
I know this sounds stupid but I am going to carry on anyway. I want to create an interface that implements all methods of a form, plus another one or two. But I need to know if there is an interface that defines all a forms methods etc. In the example below "System.Windows.Forms.Form" isn't an interface, but it gets my point across. Is there an interface for a form that I can substitute here? Thank you again Tony
6
1675
by: John | last post by:
Hi, Maybe someone can explain the use of "Me" to me? The example class CPoint3 uses the Me reference in the output statement: Console.WriteLine("CPoint3 constructor: {0}", Me) The text states: "This implicitely invokes the class's ToString method". This would be clear if Me.ToString was used, which I tested and works too!. Actually, Me.Anything works and gives the same results as long as Anything is a class member.
4
2362
by: SH | last post by:
I wish to create a program (really a Windows Service) that sits and waits for a client PC to communicate with it, but I can't come up with a good method of doing so. I want to have a service running on a server, waiting for clients to send it commands. The service would then do something based on the command and send the information back to the client. This is exactly what any database does. What is the best method for doing this? The...
0
1620
by: AndyB | last post by:
I'm using xsd.exe to generate a typed-dataset. Then using typed dataset tables (datatables containing two columns--a name and a value) to bind to ASP.NET dropdown list controls (for the dropdown list option values). All was fine with the binding, until I moved the dataset to a different assembly, as I found out that the DataColumn property is "Friend" (in VB.NET). Could you point me how to make the DataColumn "public", or another work...
35
3237
by: Chris | last post by:
Hi, I tried to create a class which must change the propety 'visible' of a <linktag in the masterpage into 'false' when the user is logged. But i get the error: "Object reference not set to an instance of an object" for the line 'If mpg.FindControl("lkred").Visible = True Then'. I couldn't find sofar the solution. Any help would be appreciated ... Thanks
1
1431
by: =?Utf-8?B?QnJldHRWUA==?= | last post by:
I have a child-class that inherits from a base class that implements an Interface. The child class overrides a SUB from the base class that implements a sub from the interface. (The "MapAttributesForImport" is a sub in an interface that is implemented by the base class marked 'overridable'.) This code was fine in VS2003/.net 1.1 and is in production. BUT...While upgrading to the .net 2.0, VS2005 is giving me an error that says "sub...
3
1514
by: dippykdog | last post by:
I have an IRange interface defined as... Public Interface IRange Property Min() As Object Property Max() As Object End Interface ....and I want to implement that in different kinds of range objects like IntegerRange, StringRange, WeightRange, CurrencyRange, etc. But I can't implement the interface using more specific types like this Public Class IntegerRange
0
9601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10115
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9199
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7660
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3014
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.