inheritance

  • Thread starter Thread starter Ching-Lung
  • Start date Start date
C

Ching-Lung

Hi,

C#, like Java, doesn't allow multiple inheritance of an
object, but it does allow multiple inheritance from
several interfaces.

How's the syntax if I want to inherit an object from a
base object and also from several interfaces?

class Base{ /* bla bla bla */ }
interface IOne{ /* bla bla bla */ }
interface ITwo{ /* bla bla bla */ }
interface IThree{ /* bla bla bla */ }

class Derived : Base, IOne, ITwo, IThree{ /* bla bla bla
*/ } <- ???

I understand that I can convert Base to an interface, but
what if I have a windows form application that derives
from System.Windows.Forms.Form class and also needs to
derive from WebBrowser control (say DWebBrowserEvents and
DWebBrowserEvents2 interfaces)?

Please advice, thanks!
-CL
 
Ching-Lung said:
Hi,

C#, like Java, doesn't allow multiple inheritance of an
object, but it does allow multiple inheritance from
several interfaces.

How's the syntax if I want to inherit an object from a
base object and also from several interfaces?

class Base{ /* bla bla bla */ }
interface IOne{ /* bla bla bla */ }
interface ITwo{ /* bla bla bla */ }
interface IThree{ /* bla bla bla */ }

class Derived : Base, IOne, ITwo, IThree{ /* bla bla bla
*/ } <- ???

I understand that I can convert Base to an interface, but
what if I have a windows form application that derives
from System.Windows.Forms.Form class and also needs to
derive from WebBrowser control (say DWebBrowserEvents and
DWebBrowserEvents2 interfaces)?
As long as DWebBrowserEvents and DWebBrowserEvents2 are actual
interfaces(not abstract classes or anything), it would simply be class
Derived : Form, DWebBrowserEvents, DWebBrowserEvents2. If they are something
other than interfaces, you may be out of luck, I don't know enoubh about IE
programming to tell you definitivly.
 
Back
Top