extend class and implement interface

  • Thread starter Thread starter farseer
  • Start date Start date
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?
 
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.
 
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)
 
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.
 
Back
Top