Hi
This must be an often encountered problem. I want to declare an abstract
class or an interface with nothing but several static constants so that I
can use polymorphism when I call each of them from my code. My stab at the
problem is shown below. Can anyone suggest what my most efficient workable
solution would be (i.e. I don't want to have to create instances of the
classes as they will only store constant information and I would preferably
like the member variables to be constant, static and not inheritable). They
have to be polymorphic.
The compiler, of course, complains vociferously with the code I have
detailed below due to the fact that you can't declare variables in an
interface, you can't override a constant, you can't declare constants to be
notinheritable... etc etc etc. The list is endless and I am a bad java
programmer trying to do vb.net :-)
I would be very grateful for any suggestions that don't involve giving up
programming.
Many thanks
Iain
Public Interface MyInterface
MustOverride Public Const Shared myVariable as String
End Interface
Public Class MyClass1
Implements MyInterface
Public Overrides NotInheritable Shared Const myVariable As String =
"MY_VARIABLE1"
End Class
Public Class MyClass2
Implements MyInterface
Public Overrides NotInheritable Shared Const myVariable As String =
"MY_VARIABLE2"
End Class