Can I allow varying types on a MustOverride

  • Thread starter Thread starter Eidolon
  • Start date Start date
E

Eidolon

I am looking to have a base class which provides that all inherited
classes MUST have some property, but that they can each define it as
whatever type they want. So maybe three class inherit from the base
class, each MUST have a [Type] property, but one defines it as
OracleType, one as SqlType and one as DB2Type, for example.

I know i can just declare it as Object, and then have the classes each
do typechecks on value assignment, but this is late-bound. I would like
some way to implement this so that the type-specificity of each class is
early-bound, allowing for compile time type checking.

Is this possible?

TIA-
- Aaron.

==============================================================

This is what i want (generic code)...

Class BaseClass
Public MustOverride Property Type

... other class code ...
End Class

Class OraClass
Inherits BaseClass

Public Overrides Property Type As OracleType

... other class code ...
End Class

Class SqlClass
Inherits BaseClass

Public Overrides Property Type As SqlType

... other class code ...
End Class
 
The only way I know of to do this is via polymorphism, if all the
types support a common interface. For example:

Class BaseClass
Public MustOverride Property Type As INativeDBType

... other class code ...
End Class

If OracleType and SqlType both implement interface INativeDBType, your
derived classes should work as declared below. Replace "INativeDBType"
with whatever the common interface is, if there is one. If not, I
don't think this can be done early-bound.
 
Back
Top