F
Franco Gustavo
Hi,
Please help me to understand this, because I don't see what I'm missing.
I was reading a lot of examples on Internet that explain that C# doesn't
implement multiple inheritance it implement multiple interfaces.
So, I keep reading and reading and reading to see how can I resolve my
problem with interfaces.
The conclusion is I'm writing to all of you because I couldn't find the way
to resolve my problem.
If I can create multiples interfaces and I have to implement the methods on
the derived class, then what's the big deal.
I know if I declare a class that inherit from one interface is useful
because for example
I can create an Interface called Shape, and 3 Classes called Circle,
Rectangle, and Line.
If on my interface I declare my method Draw(); and I implement on each
derived class then I could do the next.
IShape s = (IShape) AnyShapeObject;
s.draw();
I think is very useful and I used many times. But now the question is what
is the similitude between Multiple Inheritance and Multiple Interfaces???? I
don't see too much
Why on Internet always speak for Multiple Inheritance and Multiple
Interfaces like they have a relation???
My Case:
I have many Windows Control and I'm inherit each one for create my own
Controls.
For example I want to add method called getVirtualSize();
I create and interface
IVirtualSize
It contain
public getVirtualSize();
So, on my derived class I MUST implement my method getVirtualSize and that's
it.
Very nice!!!
Now the real question is, I create a lot of logic on my paint method; this
logic is exactly the same for all derived classes, why do I have to
implement this entire logic on each Control???
With multiple inheritances you just create a class
ExtendedControlFuncionality and Implement a method OnPaintEx, and really I
have a nice source code, because my class ExtendedControlFuncionality has
all the new extended functionality.
Then how can I do the same with interfaces????
I don't want to put my piece of code on every derived class, it is a mess
and very difficult to maintain, I want to centralize my source code and in
the same time I want to use many methods of the base classes, that means I
want to use all the protected methods that the controls offer to me because
OnPaintEx needs those.
Really, here is only one example, the reality is that is a lot of source
code that I "should" implement on every Control, I don't want to do that.
Thanks, the answers will be really appreciated.
Gustavo.
Please help me to understand this, because I don't see what I'm missing.
I was reading a lot of examples on Internet that explain that C# doesn't
implement multiple inheritance it implement multiple interfaces.
So, I keep reading and reading and reading to see how can I resolve my
problem with interfaces.
The conclusion is I'm writing to all of you because I couldn't find the way
to resolve my problem.
If I can create multiples interfaces and I have to implement the methods on
the derived class, then what's the big deal.
I know if I declare a class that inherit from one interface is useful
because for example
I can create an Interface called Shape, and 3 Classes called Circle,
Rectangle, and Line.
If on my interface I declare my method Draw(); and I implement on each
derived class then I could do the next.
IShape s = (IShape) AnyShapeObject;
s.draw();
I think is very useful and I used many times. But now the question is what
is the similitude between Multiple Inheritance and Multiple Interfaces???? I
don't see too much
Why on Internet always speak for Multiple Inheritance and Multiple
Interfaces like they have a relation???
My Case:
I have many Windows Control and I'm inherit each one for create my own
Controls.
For example I want to add method called getVirtualSize();
I create and interface
IVirtualSize
It contain
public getVirtualSize();
So, on my derived class I MUST implement my method getVirtualSize and that's
it.
Very nice!!!
Now the real question is, I create a lot of logic on my paint method; this
logic is exactly the same for all derived classes, why do I have to
implement this entire logic on each Control???
With multiple inheritances you just create a class
ExtendedControlFuncionality and Implement a method OnPaintEx, and really I
have a nice source code, because my class ExtendedControlFuncionality has
all the new extended functionality.
Then how can I do the same with interfaces????
I don't want to put my piece of code on every derived class, it is a mess
and very difficult to maintain, I want to centralize my source code and in
the same time I want to use many methods of the base classes, that means I
want to use all the protected methods that the controls offer to me because
OnPaintEx needs those.
Really, here is only one example, the reality is that is a lot of source
code that I "should" implement on every Control, I don't want to do that.
Thanks, the answers will be really appreciated.
Gustavo.