473,401 Members | 2,068 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,401 software developers and data experts.

extend class and implement interface

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?

Nov 17 '05 #1
5 38367
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"farseer" <fa*****@optonline.net> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
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?

Nov 17 '05 #2
great, thanks much~

Nov 17 '05 #3
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)

Nov 17 '05 #4
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"farseer" <fa*****@optonline.net> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
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)

Nov 17 '05 #5
thanks once again!

Nov 17 '05 #6

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

Similar topics

3
by: Tony Johansson | last post by:
Hello! When a class implaments an Interface must the class implement all methods? Whan happen if the class don't implament all methods in the interface. Will it cause compile error then. ...
2
by: Derrick | last post by:
Is there an implement interface wizard is C#/Visual Studio? And, I have an interface, with many implentations, want to provide a Web Service implementation. What would be the standard practice? ...
9
by: phl | last post by:
hi, I am kind of confused aobut interfaces and abstract classes. In short as I understand it, an interface is like a contract between the class and the interface, so that certain funtions must...
10
by: Brett | last post by:
I'm still trying to figure out concrete reasons to use one over the other. I understand the abstract class can have implementation in its methods and derived classes can only inherit one abstract...
10
by: Joe | last post by:
My question is more an OOD question. I know *how* to implement both abstract classes and interfaces. Here's my question - under what circumstacnes does one use an abstract class and under what...
7
by: moondaddy | last post by:
If I'm in a class that inherits an interface, is there a shortcut key that will write the implementation of the interface into the class? I remember seeing something like this in vb.net. ...
52
by: Ben Voigt [C++ MVP] | last post by:
I get C:\Programming\LTM\devtools\UselessJunkForDissassembly\Class1.cs(360,27): error CS0535: 'UselessJunkForDissassembly.InvocableInternals' does not implement interface member...
5
by: Tony Johansson | last post by:
Hello! The only reason I can see interface to be implemented explicitly is when the a class implement two interface having the same method signature. In all other cases I can implement interface...
3
by: =?Utf-8?B?Sm9uIEU=?= | last post by:
I have an interface class with maybe eight functions, defined in one workspace and am defining a class in a second workspace that derives from this interface. Unfortunately only 7 of the 8...
7
by: Peter Morris | last post by:
interface Interface1 { } interface Interface2 : Interface1 { } class A : Interface2 {
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.