Re: Class casting.



Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,



Thanks.
I did similar thing.
I created a base class and all pages inherit from this base class.
The reason was, that I had different methods in classes.


You mean methods with different signature?
Cause if they have the same signature, well that the idea of using an interface in the first place !

Yes I know, but it's existing application which I moves to VS2005 and somebody used different names for each class. I didn't want to changed it. Maybe later, when I have time



Inteface forces me to implement all of them in each class.


Or you could implement several interfaces, but what I do not understand is how you call the different methods if they have different signatures.


:)

huge case

:)



Virtual methods in base class allow me to implement only needed method,


What about different interfaces?



To much work. 15 interfaces and one method in each.
it was easier to impelemt one base class with 15 virutal methods.
I had to changed inheritance in 15 classess and casting class in that huge case.




.



Relevant Pages

  • Re: Abstract Class vs. Interface
    ... A class that inherits from an abstract base class can choose ... Often interfaces represent a set of capabilities for example: ... class Apple: Fruit, Eatable ... It is unlikely that class Cow and class Apple would inherit from the same ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Abstract Class Theory
    ... >> there would be no need for abstract methods, and no abstract classes. ... >> the derived class will be overriding, or even overloading, the base class ... > class inherit from both. ... Actually you are confusing abstract classes and interfaces. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Class casting.
    ... I created a base class and all pages inherit from this base class. ... The reason was, that I had different methods in classes. ... You mean methods with different signature? ... Or you could implement several interfaces, but what I do not understand is ...
    (microsoft.public.dotnet.languages.csharp)
  • Exposing C# to COM / Inheritance of objects/interfaces
    ... I have ComVisible set to true for the entire assembly. ... I have base class A. ... There are interfaces IA and IAEvents for accessing properties of this object ...
    (microsoft.public.dotnet.framework.interop)
  • IGNORE - Re: Exposing COM & inheritance problems
    ... I have base class A. ... There are interfaces IA and IAEvents for accessing properties of this ... object and exposing events. ... when I then add a IBEvents (deriving from IAEvents) and change ...
    (microsoft.public.dotnet.languages.vc)

Loading