extend class and implement interface

F

farseer

Hi,
is it possible to both extend a class and implement an interface in C#?

i am having a hard time figuring this out. i would like to do
something like this:


class MyClass extends MyBaseClass implements IBehavior1,IBehavior2

how can i do this?
 
N

Nicholas Paldino [.NET/C# MVP]

farseer,

In C#, you just do this:

class MyClass : MyBaseClass, IBehavior1, IBehavior2

The base class that you derive from always has to come first. Other
than that, it's that simple.

Hope this helps.
 
F

farseer

btw, is there a simple way in Visual Studio to add the interface stubs
to classes that implement interfaces? just curious...(i was a big fan
of Eclipse and IntelliJ editors because of little things like these)
 
N

Nicholas Paldino [.NET/C# MVP]

farseer,

In VS.NET 2003 and beyond, if you place the cursor on the interface name
in the class declaration, a smart tag will appear. Clicking it will give
you the option of explicitly implementing or implicitly implementing the
interface.
 

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

Top