473,473 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

C# Inheritance and Interfaces

I'm a novice programmer just beginning to learn the new C#
language.

I'm a bit confused about the way Inheritance and
Interfaces are constructed in C#. The following examples
may help clarify my confusion:

interface IControl
{
void Paint();

}

interface ITextBox: IControl
{
void SetText(string text);
}

public class IControl
{
void SetText(string text);
}
public class EditBox : IControl
{
public void Paint() {...}
public void Bind(Binder b) {...}
}

Can the designers of the language ponder over this and
maybe think of a way to remove this confusion in future
releases of the language?

I was wondering., wouldn't it be better to use the more
clearer VB-style or Java-style methods of invoking
inheritance and interface? After all this is not the era
of the criptic C++ style way of programming. I think this
would remove the confusion a great deal.

e.g.

interface ItextBox implements Icontrol {}

AND
public class EditBox inherits Icontrol {}
etc.
Flavian Musyoka Mwasi
Nairobi, Kenya
Nov 16 '05 #1
2 2152
Flavian Musyoka Mwasi <mu******@hotmail.com> wrote:
I'm a novice programmer just beginning to learn the new C#
language.

I'm a bit confused about the way Inheritance and
Interfaces are constructed in C#. The following examples
may help clarify my confusion:

interface IControl
{
void Paint();

}

interface ITextBox: IControl
{
void SetText(string text);
}

public class IControl
{
void SetText(string text);
}
Hang on - you've now got two types called IControl - one an interface,
one a class. That's a really bad idea. Was it what you intended.
public class EditBox : IControl
{
public void Paint() {...}
public void Bind(Binder b) {...}
}

Can the designers of the language ponder over this and
maybe think of a way to remove this confusion in future
releases of the language?
What confusion?
I was wondering., wouldn't it be better to use the more
clearer VB-style or Java-style methods of invoking
inheritance and interface?


Interfaces in C# are very similar to interfaces in Java.

I'm still missing what your actual problem with how interfaces work in
C# is.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Hi Flavian
there should be no problem with that . In fact it is redundant to say
inherit or implements. If it is an interface then implement if it is class
then inherit. So you don't have to repeat these words since you know your
are referring to class or interface. Also there is the naming convention
that is supposed to make things even more clear; use only the capital I as
a prefix for interface name . I think all these factors more clearly rather
than cryptic.
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #3

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

Similar topics

3
by: Joe Delphi | last post by:
Does Visual Basic support multiple inheritance? That is one child class inheriting from more than one parent class. JD
8
by: Shawn Casey | last post by:
Consider the following code: interface IBase { virtual void BaseFunction() = 0; }; interface IDerived : public IBase { virtual void DerivedFunction() = 0;
12
by: Steve Jorgensen | last post by:
The classing Visual Basic and VBA support for polymorphism, let's face it, is a bit on the weak side, and built-in support for inheritance is non-existent. This little essay is about some patterns...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
15
by: Sinex | last post by:
Hi, Why does C# disallow multiple inheritance? Whats the reason behind this? Is there any advantage or is it just a method to avoid some problems (if so, what problems?) that come with multiple...
7
by: Hazz | last post by:
Are there any good references/articles/books which provide clarity toward my insecurity still on deciding how to model a complex system? I still feel uncomfortable with my understanding, even...
0
by: Terry Hancock | last post by:
I've been discussing PyProtocols with a a friend collaborating with me on a SF game project, about the benefits and design concept of "component architecture", and I'm a little confused by what...
23
by: Dave Rahardja | last post by:
Since C++ is missing the "interface" concept present in Java, I've been using the following pattern to simulate its behavior: class Interface0 { public: virtual void fn0() = 0; };
18
by: GD | last post by:
Please remove ability to multiple inheritance in Python 3000. Multiple inheritance is bad for design, rarely used and contains many problems for usual users. Every program can be designed only...
3
by: johanatan | last post by:
When I first heard about these new features, I was very excited as it would have (if implemented as I had expected) rendered mimicking multiple inheritance almost painless in C#. Unfortunately,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.