Inheritance question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hey,

I want to inherit an abstract class and MessageWindow class.
can we do that?

for example,

abstract class SomeClass
{
public void SomeMethod()
{
// do something
}
}

can I create a new class which inherits both the above abstract class and
MessageWindow class?

public class MyClass : SomeClass, MessageWindow
{

}

Kindly let me know,

Cheers,

Naveen.
 
no for that you'd need an interface

e.g.

public interface IMessageWindow {
public void DoSomething();
}

public class MyClass : SomeClass, IMessageWindow
{
// .... other methods/constructir etc.

#region IMessageWindow implementation

public void DoSomething() {
}

#endregion
}

this way classes implementing the interface are forced to implement certain
methods.

HTH
Sam
 
Just to expand on the answer below, you can inherit from only one class, but
as many interfaces as you like.
 
hi
C# does not support multiple inheritance.
You can inherit only from one class .
But you can implement multiple interfaces

Regards
Ansil Trivandrum
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top