473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

problems with inheritance???

Hi..

I have a standard windows app in C#. The project contains a two forms and one class that i have created. I want both of the forms to inherit from the class but i am getting an error reading "type in interface list is not an interface"??? i am not sure how to fix the problem. Is an interface (form) unable to inherit from a non interface type??

any help appreciated
Nov 15 '05 #1
2 3914
Darryn,
this is a little confusing because a "form" is not an interface, it is a class.
Perhaps with some code example we can get a better insight into what your goal really is.
You can't get the properties of a Windows Form class by having a class derive from another class that doesn't inherit itself from System.Windows.Forms.Form.
--Peter
"Darryn Ross" <da****@datawave.com.au> wrote in message news:Ow**************@TK2MSFTNGP11.phx.gbl...
Hi..

I have a standard windows app in C#. The project contains a two forms and one class that i have created. I want both of the forms to inherit from the class but i am getting an error reading "type in interface list is not an interface"??? i am not sure how to fix the problem. Is an interface (form) unable to inherit from a non interface type??

any help appreciated
Nov 15 '05 #2
"Darryn Ross" <da****@datawave.com.au> wrote in message news:Ow**************@TK2MSFTNGP11.phx.gbl...
The project contains a two forms and one class that i have created.
I want both of the forms to inherit from the class but i am getting an error


Form is a class, not an interface. Therefore, the form (which inherits
from System.Windows.Forms.Form) has already used up its one
permitted inheritance, and cannot simultaneously inherit from the
other class you have created.

C# only supports single inheritance, not multiple inheritance like C++.

The workaround is to aggregate this other class, such that your form
still inherits from form, but your form subclass must:

1. Contain an instance of the other class you've created in the
constructor as a member field.

2. Expose the methods and properties of the class you've created.

Aggregating the class, I'll call it T, in lieu of inheriting from it, would
look something like this:

public class F : Form
{
private T impl;
public F( ) { impl = new T( ); }
public int Foo( int x) { return impl.Foo( x); }
}

Normally, its desirable to make the methods and properties of the
aggregated class to be defined in an interface. Then anyplace where
you might ordinarily expect an instance of this class, you would use a
reference to this interface instead. The form class, instead of inheriting
from two classes, could inherit from one class and implement the interface
of the aggregated object (which supplies the actual implementation of
the interface and is delegated to by the form).

In a more interface or type-driven manner such as this, not having multiple
inheritance is not a problem.
Derek Harmon
Nov 15 '05 #3

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

Similar topics

2
by: Matt | last post by:
I have created an MDI child form that I am using as a base form in a VB.Net MDI application. The base MDI child form has a series of menu options on it. I then use this form to create other MDI...
13
by: John Perks and Sarah Mount | last post by:
Trying to create the "lopsided diamond" inheritance below: >>> class B(object):pass >>> class D1(B):pass >>> class D2(D1):pass >>> class D(D1, D2):pass Traceback (most recent call last): File...
4
by: Alex Hunsley | last post by:
I've seen a few discussion about the use of 'super' in Python, including the opinion that 'super' should only be used to solve inheritance diamond problem. (And that a constructor that wants to...
3
by: Roman S. Golubin1709176985 | last post by:
All how do you do! Who what cases uses for C# programming? I have an experience with Microsoft Visio several days. He has a problem with interface inheritance... óan who that other advise? ...
5
by: Mac via DotNetMonster.com | last post by:
Hi all, I have a creating a my own tabpage class (MyTabPage) which inherits the .Net TabPage class. In the relevant event I want to loop through the collection of TabPages and then when I...
1
by: George Durzi | last post by:
I'm converting a c# web application to support page inheritance so that I can really change the look and feel of my application by only modifying the ..cs that my pages inherit from. The only...
1
by: bill | last post by:
What's up with inheritance in code behind? Is it reliable, or should I skip it and forget about using inheritance in web forms until they get it right? I'm using VB.NET 2005 I have a web form...
2
by: beseecher | last post by:
Hi, In my research in the javascript language I have encountered problems with implementing prototype inheritance while preserving private methods functioning properly. Here is an example: ...
3
by: djboyse | last post by:
Hey, I'm kind of new to C++ and having some problems with inheritance. I've tried looking everywhere for some help, but I'm not too sure what to ask so please any input will be greatly...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.